c# 4.0 - How to save text files or excel files in local folder in windows phone -


how save text files or excel files in local folder in windows phone? text files web service response http url, how save them in local folder? more ideas see code below. thanks!!

uri uri = new uri("https://abcd/xyz/def"); webclient wc = new webclient(); wc.downloadstringasync(uri); wc.downloadstringcompleted += wc_downloadstringcompleted;  void wc_downloadstringcompleted(object sender, downloadstringcompletedeventargs e) {         string result = e.result.tostring();          messagebox.show(result);          isolatedstoragefile myisolatedstorage = isolatedstoragefile.getuserstoreforapplication();          string foldername = "localfolder\\mydata\\";         myisolatedstorage.createdirectory(foldername);         string filepath = system.io.path.combine(foldername, "myfile.txt");          using (streamwriter write = new streamwriter(new  isolatedstoragefilestream(filepath, filemode.create, fileaccess.write, myisolatedstorage)))         {             write.writeline(result);             write.close();         } } 

use below code write .txtfile:

 void wc_downloadstringcompleted(object sender, downloadstringcompletedeventargs e)         {             string response = e.result.tostring();             isolatedstoragefile myisolatedstorage = isolatedstoragefile.getuserstoreforapplication();              //set file path                string foldername = "localfolder\\mydata\\";              myisolatedstorage.createdirectory(foldername);              string filepath = system.io.path.combine(foldername, "myfile.txt");               //create new file             using (streamwriter writefile = new streamwriter(new  isolatedstoragefilestream(filepath , filemode.create, fileaccess.write, myisolatedstorage)))             {                     writefile.writeline(response);              writefile.close();             }         } 

and check file saved or not:

if (myisolatedstorage.directoryexists("localfolder\\mydata\\")) { string[] filenames = myisolatedstorage.getfilenames("localfolder\\mydata\\*"); } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -