In my windows application foe exporting the data in data grid I want to prompt the user to give the name of the file as his/her wish.But present I implemented code to store the file with unique name and it also produce error also while I export another file to that path i.e., the path is already exists with another process.
I used this code to export the data:
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter("D:\\outputs.csv")
string strHeader = dataGridView1.Columns.HeaderText;
for (int i = 1; i < dataGridView1.Columns.Count; i++)
strHeader += "," + dataGridView1.Columns[i].HeaderText;
for (int m = 0; m < dataGridView1.Rows.Count; m++)
string strRowValue = "";
strRowValue += dataGridView1.Rows[m].Cells.Value;
for (int n = 1; n < dataGridView1.Columns.Count; n++)
strRowValue += "," + dataGridView1.Rows[m].Cells[n].Value;
the code just save the data with that outputs
name for only once.But I want to save different file with different names in different locations.
So,Please provide the solution to store the file with different names.
Thanks In Advance.,