Read file c# windows 8 -


few weeks ago asked similar question in topic write , read file , question answered, i'm trying read file , use if function, @ moment can read textblock pressing button read file , transfer txtblock, want know how able read not using way. @ moment here.

 private async task readfile()     {         // local folder.         storagefolder local = windows.storage.applicationdata.current.localfolder;          if (local != null)         {             // datafolder folder.             var datafolder = await local.getfolderasync("level");              // file.             var file = await datafolder.openstreamforreadasync("level.txt");              // read data.             using (streamreader streamreader = new streamreader(file))             {                 this.textblock1.text = streamreader.readtoend();             }          }     }       private async void button_click(object sender, routedeventargs e)     {         await readfile();          if (textblock1.text == "test")             star2.visibility = visibility.visible;     } 

took second figure out think mean.

        using (streamreader streamreader = new streamreader(file))         {             this.textblock1.text = streamreader.readtoend();         } 

try this:

        string readtxt;         using (streamreader streamreader = new streamreader(file))         {             readtxt = streamreader.readtoend();         } 

now have string variable 'readtxt' works in ways string type , contains contents of file.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -