How to use external files both during development & deployment

ppsa

Member
Joined
Sep 28, 2008
Messages
13
Programming Experience
10+
My vb.net windows forms application plays wav files. I want to allow the user to "import" their own wav files in addition to the ones I provide already in the app. Right now, the wav files are stored in My.Resources and played from there, so ideally, I'd add their wav files to My.Resources, but, from what I have learned, this is not possible to do dynamically at runtime. So, plan B: Give the user a browse button, and copy their wav files to a folder where I then access them and play them in the app. I'd like to put their wav files in a WAV folder I create in the application folder.

Part 2 of the story: I also have a setup project that creates a setup.exe. How can I ensure that the setup program will copy that folder and its contents, put it in their application folder during installation, then find it there when it runs after setup?

Thanks for your help!
 
I'd like to put their wav files in a WAV folder I create in the application folder.
OK. So, what have you done and what are you having trouble with? Break it down: click a Button, display an OpenFileDialog, copy the file. There's not much to it.
How can I ensure that the setup program will copy that folder and its contents, put it in their application folder during installation, then find it there when it runs after setup?
Is it even worth bothering? If the folder will be empty at that point then you could simply create it when you copy the first file. If you really want to create the folder at installation then we're going to need to know what technology you're using to create the installer because the answer will depend on that. If you're using ClickOnce then I'm not sure that it's possible. I think that you can deploy files in subfolders but if a subfolder is empty then it's ignored by the publish process.
 
I haven't "done" anything because I don't know what to do. I am looking for guidance.

I'm using the Setup project creation capability in Visual Studio (2010). As I mentioned, I want to include my own wav files during installation, so I want the setup to deliver a folder with those wav files already in it and to which users can add using the browse button that you mentioned and as I originally described. What I am having trouble with is this: How do I set things up so that I have that folder in the application folder BOTH when I'm developing and after it's been deployed, given that the application folder will not necessarily be in the same location?
 
Let me rephrase the question and hopefully simplify it: When I'm developing my app, I have a folder in the application folder. How do I get that folder, and all its contents, to appear in the USER's application folder after performing a setup developed by the setup project capability in VS2010?

Again, thanks for the help.
 
As JohnH says, you really shouldn't be using the program folder to ad files to after deployment. If you're using Windows Installer then you'll likely be installing under Program Files and some users don't have write access in that case, so adding a new file would fail.

If you really want top go that way then I believe that all you actually need to do is add the folder to your project in the Solution Explorer, add your files to that folder and then set their Build Action property to Content and their Copy To Output Directory property to True. I haven't used a Setup project for a long time but I believe that all Content files can be selected as a single output to be included in your installer. In code, you simply use Application.StartupPath to get the path of the program folder. You can use Path.Combine to add the name of the folder containing the files and you can use Directory.GetFiles to get all the paths of the files in that folder.
 

Latest posts

Back
Top