hi everyone, does anyone have an idea on how to programmatically refresh the solution explorer in asp.net/c# or
vb.net, i am exporting a gridview to an txt file and upload it, after that i've added the lines of code that will force the file to be downloaded to the client machine, so after uploading it can't locate and open the file because the solution explorer needs to be refreshed manually. here's my code:
DBConnection cd = new DBConnection();
DataSet ds = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter("select requesitionid,department,vendorName from tblRequisition", cd.con);
adp.Fill(ds);
// Create the CSV file to which grid data will be exported.
string path = Server.MapPath("~/Payment.txt");
StreamWriter sw = new StreamWriter(path);
// First we will write the headers.
DataTable dt = ds.Tables[0];
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
sw.Write(dt.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
// Now write all the rows.
foreach (DataRow dr in dt.Rows)
{
for (int i = 0; i < iColCount; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(dr[i].ToString());
}
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
}
sw.Close();
/
/the downloading part starts here
System.IO.FileStream fs = null;
fs = System.IO.File.Open(Server.MapPath(path), System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=" + path);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();
Thanks in advance.
