Charles Baldo
asked on
File Downlaod
I am creating a .csv file on my server then I want to be able to let the user download it. I have this code and it creates a file but instead of letting them download it displays it on the browser
// create a writer and open the file
TextWriter tw = new StreamWriter(@"C:\Inetpub\ websites\w ebsite.net \app_data\ downloads\ work.csv") ;
// write a line of text to the file
tw.WriteLine("test,123,99. 85,$100.34 ");
// close the stream
tw.Close();
Response.Write("Download") ;
Response.ContentType = "text/csv";
Response.AddHeader("conten t-disposit ion", "attachment; filename=work.csv");
FileStream sourceFile = new FileStream(@"C:\Inetpub\we bsites\web site.net\a pp_data\do wnloads\wo rk.csv", FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent , 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getCo ntent);
// create a writer and open the file
TextWriter tw = new StreamWriter(@"C:\Inetpub\
// write a line of text to the file
tw.WriteLine("test,123,99.
// close the stream
tw.Close();
Response.Write("Download")
Response.ContentType = "text/csv";
Response.AddHeader("conten
FileStream sourceFile = new FileStream(@"C:\Inetpub\we
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent
sourceFile.Close();
Response.BinaryWrite(getCo
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.