How do I embed and read a text file ina WP7 app?

后端 未结 2 705
离开以前
离开以前 2020-12-16 22:49

I\'m trying to include a text file that contains some static data that I need to read in when the app starts up. I\'ve added the file and marked the Build Action to \"Resour

2条回答
  •  自闭症患者
    2020-12-16 23:54

    try this:

    var resource = Application.GetResourceStream(
                                   new Uri(@"/YOURASSEMBLYNAME;component/Stations.txt", 
                                   UriKind.Relative));
    
    StreamReader streamReader = new StreamReader(resource.Stream);
    
    string x = streamReader.ReadToEnd();
    

    That should work for you.

提交回复
热议问题