Reading a text file in Windows 8

I am having trouble reading the embedded resource (text file) in windows-8 , I usually use Assembly.GetExecutingAssembly() , but I cannot do this in this. I refer to the System.Reflection namespace, but it says that it cannot find, thinking it might be deleted.

Any ideas?

Currently using Windows 8 Preview

code: Assembly readAssembly = Assembly.GetExecutingAssembly(); StreamReader streamReader = new StreamReader(readAssembly.GetManifestResourceStream("Test.txt")); Assembly readAssembly = Assembly.GetExecutingAssembly(); StreamReader streamReader = new StreamReader(readAssembly.GetManifestResourceStream("Test.txt"));

Error: System.Reflection.Assembly 'does not contain a definition for' GetExecutingAssembly '

+8
c # windows windows-8
source share
3 answers

In WinRT, resources must be included in the package. You use Package.Current.InstalledLocation.GetFileAsync to read the resource.

The following publication has sample code:
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/d4b327e3-a8f2-4d3c-8ed7-ba2ea953d0b9

+8
source share

In the AppStore libraries you can use the following code:

 Stream stream = this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream(fileName); 
+2
source share

Why don't you use the ReadFileAsync () method available in VS 2012. Add a text file to the project and call the async method

+1
source share

All Articles