Dynamically add file to Project using C #

How to add a file to a project at runtime in a project folder using C #.

I want to add images, videos and other objects to my project with the click of a button so that anyone (users of my application) can easily add these things.

-2
c # silverlight
source share
1 answer

And finally, we will find out the actual question.

Basically, there are two ways to do this.

Quick and easy. Right click on your project in solution explore. Choose Add existing file. Select the file(s), you want to deploy. 

Now they are in the solution folder, when you create them, they go to the bin folder. If yours does not happen. Right clieck on one, select properties, in the Property window should always be copied or copied if it is newer.

Then your program will be able to "see" them in the same folder as itself.

Another option is to add them as resources.

 Right click on project. Select properties. Select resources tab. Add existing files. 

Now they will be compiled as resources in your exe, cannot receive them directly in the file system (this is really necessary), but they will never be lost.

And last but not least, deployment requires a script up and adding a data folder to the application, which will depend on what you use for deployment and other things.

-one
source share

All Articles