Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a .txt file Resource in VB

Right now i have a line of code, in vb, that calls a text file, like this:

Dim fileReader As String
    fileReader = My.Computer.FileSystem.ReadAllText("data5.txt")

data5.txt is a resource in my application, however the application doesn't run because it can't find data5.txt. I'm pretty sure there is another code for finding a .txt file in the resource that i'm overlooking, but i can't seem to figure it out. So does anyone know of a simple fix for this? or maybe another whole new line of code? Thanks in advance!

like image 660
Tony C Avatar asked Apr 18 '10 14:04

Tony C


1 Answers

If you added the file as a resource in the Project + Properties, Resources tab, you'll get its content by using My.Resources:

Dim content As String = My.Resources.data5

Click the arrow on the Add Resource button and select Add Existing File, select your data5.txt file.

like image 176
Hans Passant Avatar answered Oct 10 '22 17:10

Hans Passant