Keeping files together within .NET

A

aaj

Hi all

I have a group of files that I store independently in a temporary folder on
the c: drive. Typical things are ini files, bitmaps, icons etc. All access
to the files is hardcoded within my software

e.g.
private Bitmap myTick = new Bitmap(@"C:\TempManager\tick.gif"); etc....

What I would like to do is have the contents of \TempManager become
completely associated with my project and address the folder 'non
absolutely' so when I finally package it, these associated files are
embedded into the setup.exe file and then when the user installs, they are
created in a directory that is related to the chosen installation program
folders directory, with my code still able to find the files.

I have tried adding a new folder within my project, but if I select add
existing items, I can only add certain things i,e, .cs files, .bmp files
etc.

In summary, I would like to add all my non c# working files to my project,
have all my code look at a ''virtual directory' and then when it's
regenerated on a clients PC using the MSI installer, have all the files
stored in a folder that sits underneath the program folder, and have the
'virtual directory' used by my code point to wherever the user decided to
install.

I hope this all makes sense, it sounds complicated, but what I'm trying to
acheive is pretty simple.

many thanks

Andy
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

This is a bad idea, you should not hardcode paths , instead use paths
relatives to the install dir of the app.
You can add a file in your setup project. additionally you could add those
files as embedded resources and they will be packed inside the finished
product ( .exe or .dll)

cheers,
 
A

aaj

Hi

thanks for reply, and I agree entirely.

I'll take a look at embedded resources. Perhaps thats what I need

Andy
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Use this code to create an image:
System.Drawing.Bitmap m_bitmap = new
System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream(
"icon.bmp" ));

cheers,
 
A

aaj

Many thanks

took a bit of looking up, but I'm now happily embedding all my necessary
documents

thanks again

Andy
 

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