Hai.,
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[0].HeaderText;
for (int i = 1; i < dataGridView1.Columns.Count; i++)
{
strHeader += "," + dataGridView1.Columns[i].HeaderText;
}
streamWriter.WriteLine(strHeader);
for (int m = 0; m < dataGridView1.Rows.Count; m++)
{
string strRowValue = "";
strRowValue += dataGridView1.Rows[m].Cells[0].Value;
for (int n = 1; n < dataGridView1.Columns.Count; n++)
{
strRowValue += "," + dataGridView1.Rows[m].Cells[n].Value;
}
streamWriter.WriteLine(strRowValue);
}
streamWriter.Close();
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.,
Thank You.,
Vijaya.S