I am using vb.net 2005 (express) and can't quite figure out how to do this.

I have an application that reads in a bunch of data from a file into the appropriate variable arrays like I want. I used a simple solution that I found here on DaniWeb to read in the file into a string using streamreader and then parse it out using the text deliminator using string.split. All works perfectly.

The downside is that I have to distribute the data file with the application, and I do not want to do that. Is there a way for me to "add" the file to my project and read the data from this embedded resource? I can seem to add it just fine, but I can't quite sort out how to properly reference it and use the streamreader to again read the columns of data into a string.

thanks for any help.

Recommended Answers

All 5 Replies

Welcome Raouldukey.

Please follows
1. Select your data file.
2. In properties windows - set Copy To Output Directory with "Copy is newer" (In this way a file in your project will automatically added to your deploment folder - \debug\bin.)

Thanks for the suggestion, but I don't think that does at all what I am wanting to do. It will certainly make a copy of the file in the bin directory, but then I am still forced to send that file out with my executable. Also, I don't really want to give anyone the raw data file.

Double click on "My Project" in the solution explorer, select resources, and "Add Existing File". You can navigate to the file and embed it as a resource.

Note -- You can use tools like resource hacker or resource thief (i forget the name) to extract the raw data file. It isn't easy to pull out resources but it isn't impossible either. You can encrypt the resource before you add it if you want, then decrypt it when you access it.

Here is a screenshot of the section where you can embed the resource

Dang... I wish I would have seen this earlier and just embedded it as a string like I think you are suggesting.

What I did in the end (and it actually works!!!) is to embed the file as a resource into my project. I then used the GetManifestResourceStream method to read the contents of the file into a stream. Once I knew what to search for, it didn't take too long to find an example of what I was trying to do, as the GetManifestResourceStream documentation was a big hard for me to follow.

thanks for the help though, and I would consider this one closed.


Double click on "My Project" in the solution explorer, select resources, and "Add Existing File". You can navigate to the file and embed it as a resource.

Note -- You can use tools like resource hacker or resource thief (i forget the name) to extract the raw data file. It isn't easy to pull out resources but it isn't impossible either. You can encrypt the resource before you add it if you want, then decrypt it when you access it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.