Create a CSV download using silverlight 4 and c# -


i'm struggling find example or code able create csv or text file in silverlight downloadable link.

i've done in asp.net can't figure out way using silverlight. spinning wheels? or should create asp page? there way of doing in c#?

i'd right way , not hack job , appreciate feedback , advice.

in asp of used:

response.contenttype = "text/csv" response.addheader "content-disposition", "attachment;filename=""epic0b00.csv""" response.write.... 

i able solve similar code above, including required references there no assumptions made, plus actual working example.

using system;   using system.io; using system.windows;   using system.windows.controls; ....      private void btnsave_click(object sender, routedeventargs e)     {         string data = exportdata(); // data built         savefiledialog sfd = new savefiledialog()         {         defaultext = "csv",         filter = "csv files (*.csv)|*.csv|all files (*.*)|*.*",         filterindex = 1         };         if (sfd.showdialog() == true)         {             using (stream stream = sfd.openfile())             {                 using (streamwriter writer = new streamwriter(stream)) {                 writer.write(data);  //write data :)                 writer.close();                 }                 stream.close();              }         }     }      private string exportdata()     {        return "!this exported text";     } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -