Jeremy Griffin
Jeremy Griffin

Reputation: 107

How do you add files to projects?

Im currently trying to add 2 files to my project. One of them is a .ovpn (vpn Config file) and the other is a batch file.

Im trying to create a directory in my code and then add these files to that newly created directory so when the users first run's this application it creates the files needed to run the application.

Is there anyway of adding these files like a resource so I can just reference them easy?

Sorry if this is a really simple question. Just never done it before.

Thankyou in advance!

Upvotes: 0

Views: 46

Answers (2)

Baaleos
Baaleos

Reputation: 1825

You don't need to necessarily have them embedded in the executable to have them easily referenced.

Add a 'resources' type object to your project - call it Resources.res Right click on your project, make a New Folder Call it 'Resources' - add your resource files in here. Double click on your Resources.res file Click on the 'Add New Existing File' Navigate to your file that is in the Resources directory and select it. You should see your file showing up inside the resources viewer now.

When you are writing code, you can now reference your added files via:

Resources.<nameoffile>

If your file is a text file, you can do things like

string jsonRequest = Resources.RegistrationRequest;

This should automatically set the files to be embedded as well, so they should be accessible at run time.

Upvotes: 0

Dmytro Tysko
Dmytro Tysko

Reputation: 73

You can try to change properties of your files like:

enter image description here

Upvotes: 2

Related Questions