C# save a DataGridView Directory Comparison to CSV with special filename for C# Windows App -
i created button allow user create csv based on directory comparison. compiled code, , looks ok. go run program, however, , "access denied" error.
private void button1_click_1(object sender, eventargs e) { string csv = string.empty; folderbrowserdialog fbd = new folderbrowserdialog(); using (var sfd = new savefiledialog()) if (fbd.showdialog() == system.windows.forms.dialogresult.ok) { string folderpath = fbd.selectedpath; string filename = "dir_" + (datetime.now.toshortdatestring()) + ".csv"; file.writealltext(folderpath + "dir_" + (datetime.now.toshortdatestring()) + ".csv", csv); }
is there way save datagridview csv file extension give in filename string?
do have permission write on folder?
try use file.writealllines
:
file.writealllines(folderpath + "dir_" + (datetime.now.toshortdatestring()) + ".csv", csv);
Comments
Post a Comment