How to Write file in C#? -


 string attachment = "attachment; filename=myfile.csv";  httpcontext.current.response.clear();  httpcontext.current.response.clearheaders();  httpcontext.current.response.clearcontent();  httpcontext.current.response.addheader("content-disposition", attachment);  httpcontext.current.response.contenttype = "text/csv";  httpcontext.current.response.addheader("pragma", "public");  // logic goes here write file.  // want copy above file file.   string filepath = server.mappath("~/exportedfiles/") +"newfile.csv";  var excelfile = file.create(filepath);  excelfile.close();  httpcontext.current.response.transmitfile(filepath);  httpcontext.current.response.flush(); 

the above code not working, please suggest me. thanks.

you need create virtual directory on iis , share virtual directory directory. csv should reside in virtual directory shared location. here referenced article: http://www.codeproject.com/tips/502741/a-solution-to-problem-response-transmitfile


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -