Hi I am recently using Visual Studio 2008. My problem is I already added a text file into my project [''add new items\general\Text File''].[Is not it a embedded data like icon file or background image file ?] I want to store some data into it. But dont know how to open this file. Please any opinion will be very helpful. Thanks.
views:
38answers:
1
A:
Either place the file at some place (eg relative to .EXE) that you can reconstruct at runtime and open it.
Another approach is to add it to your resources.
If you want to read and write it, you'll have to pick another place, like Application.UserAppDataPath
.
In the Menu, select Project|Properties|Resources.
On the resources page, select "Add existing File" and pick your textfile. It will get a simplified name (like TextFile1) that is a valid C# identifier.
In your code, you can get the contents with
string s = Properties.Resources.TextFile1;
Henk Holterman
2010-08-07 11:55:04
No thats not my problem. I know how to handle file system. But my problem is I want to use embedded data which is already embedded into my project dll or exe [like icon and in that case text file].
Barun
2010-08-07 11:57:33
OK, that would be the resources option.
Henk Holterman
2010-08-07 11:58:16
Thanks for reply. I think it will be all.
Barun
2010-08-07 12:21:22