Load a resource at runtime?

J

Joe Cool

OK, I know how to play a wav file that was loaded to a project's
resource file at design time. But how to I load a WAV file at runtime
into the resource file so I later play it? And can this new resource
file with the new WAV file be saved as the project's default resource
file, available the next time the app is launched?
 
J

Joe Cool

OK, I know how to play a wav file that was loaded to a project's
resource file at design time. But how to I load a WAV file at runtime
into the resource file so I later play it? And can this new resource
file with the new WAV file be saved as the project's default resource
file, available the next time the app is launched?

Hmm, after doing some more research on this I find that it probably
cannot be done.

So, then I wonder if I can create a secondary resource file at
runtime, add objects to it, use these objects in a manner similar to
using an embedded resource, and save the resource file for loading the
next time the app is launched.

Accessing an object in the default resource file is with the string
"<AssemblyName>.file.wav". So I wonder how I would reference objects
in this secondary resource file?
 
J

Jeff Johnson

Hmm, after doing some more research on this I find that it probably
cannot be done.

I'm sure it can't.
So, then I wonder if I can create a secondary resource file at
runtime, add objects to it, use these objects in a manner similar to
using an embedded resource, and save the resource file for loading the
next time the app is launched.
Accessing an object in the default resource file is with the string
"<AssemblyName>.file.wav". So I wonder how I would reference objects
in this secondary resource file?

I say forget about the concept of resource files altogether, as it'll
probably be more trouble than it's worth if it in fact can even be done at
all. I suggest these alternatives:

1) Create a subfolder in the user's ApplicationData folder and simply store
these WAV files there. Store the names (paths) and purposes of these files
in the app's Settings file.
2) Store these files in a database. This is probably overkill.
3) If you really want them store in a single file, consider using a free Zip
library like SharpZipLib and storing them in a single Zip with no
compression (since they wouldn't compress much in the first place).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top