Reading text file from Resources
-
So I have a text file in my projects resources that I need to read into an array. It's path is: global::Project1.Properties.Resources.rar it returns byte[] How would I get information from this file? - Munty
-
Hi try this using (Stream s = this.GetType().Assembly.GetManifestResourceStream("Project1.Properties.Resources.rar")) { // Read the content into byte array. }
Hi, Thanks for replying. this.GetType().Assembly.GetManifestResourceStream("string") keeps on returning null. Doesnt matter what I use it with, even files that I successfully use elsewhere will always return a null :/ Here are one of the tests that returned a null: Object o = this.GetType().Assembly.GetManifestResourceStream("Project1.Properties.Resources._01") This shouldnt have returned a null because I've used that resource elsewhere for an image. Here is the code I used that resource for that worked: imagePanel[0] = Project1.Properties.Resources._01; - Munty
-
Hi, Thanks for replying. this.GetType().Assembly.GetManifestResourceStream("string") keeps on returning null. Doesnt matter what I use it with, even files that I successfully use elsewhere will always return a null :/ Here are one of the tests that returned a null: Object o = this.GetType().Assembly.GetManifestResourceStream("Project1.Properties.Resources._01") This shouldnt have returned a null because I've used that resource elsewhere for an image. Here is the code I used that resource for that worked: imagePanel[0] = Project1.Properties.Resources._01; - Munty
-
Finally got the damned thing to work. Turns out I could use this line: TextReader tr = new StreamReader(GetType().Assembly.GetManifestResourceStream("Project1.Resources.rar.txt")); After I fiddled with the properties file so that it returned a string instead of a byte array. Wierdly enough I can still get properties and stuff from the file from: Project1.Properties.Resources.rar I just cant do anything like read in from it when using that line. Well it's finished. Thank god for that. - Munty -- modified at 12:46 Friday 17th November, 2006