I am trying to read a text file called thedata.txt that has a list of words that I want to use in the executioner's game. I tried differently, but I cannot figure out where the file is placed, if at all when the application starts. I added the file to my project, and I tried to set the assembly properties to the content, and then to the embedded resource, but I can not find the file. I created a universal project for Windows 10. The code I tried looks like this:
Stream stream = this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream("thedata.txt"); using (StreamReader inputStream = new StreamReader(stream)) { while (inputStream.Peek() >= 0) { Debug.WriteLine("the line is ", inputStream.ReadLine()); } }
I get exceptions. I also tried to list the files in another directory:
string path = Windows.Storage.ApplicationData.Current.LocalFolder.Path; Debug.WriteLine("The path is " + path); IReadOnlyCollection<StorageFile> files = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(); foreach (StorageFile file2 in files) { Debug.WriteLine("Name 2 is " + file2.Name + ", " + file2.DateCreated); }
I donโt see the file there either ... I want to avoid hard-coding the list of names in my program. I am not sure which path is in the file.
source share