Access internal file VB.NET

I added a text file to a testapp's solution and I want to read said file. I don't remember how to do this, I know it has to do with reflections but I need a push in the right direction.

Answers


If you add the text file to a .ResX file, you can have all the benefits (dynamic updating, for instance) AND not need to worry about interacting with an actual file. VB will automatically create a class to access the file - suppose you have Resources.resx. You can access it with My.Resources.MyFile - it will return a string.


Did you add the file as a resource? In that case you can access its (String) content by just using My.Resources.name_of_file. Otherwise, the easiest way to read a text file in VB is to use the following.

Dim content = My.Computer.FileSystem.ReadAllText("filename")

I was going to write some code, but instead found a better explanation here

In your case, you'll need to use your application path instead of "C:\".


Are you talking about embedding the text file as a resource in the solution - ie compiled in?

For that you need an instance of an assembly class (referecning yours, Assembly has a static member called GetExecutingAssembly) From there you call the GetManifestResourceStream


Need Your Help

CSS :checked - change <td> background

css css-selectors

With CSS, is it possible to change the background-color of an entire &lt;tr&gt; based on whether or not an &lt;input type="checkbox"&gt; is checked?

AS3: anti alias animation by code

actionscript-3 antialiasing

So what parameters in the Advanced anti alias are close to the "animation" preset in the Flash IDE?