By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

Keeping files together within .NET

P: n/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
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"aaj" <aa*@aaj.com> wrote in message
news:1126083461.e1383050c23c0a9e2bea16b502bcf5e7@t eranews...
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

Nov 17 '05 #2

P: n/a
aaj
Hi

thanks for reply, and I agree entirely.

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

Andy
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ew**************@TK2MSFTNGP12.phx.gbl...
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"aaj" <aa*@aaj.com> wrote in message
news:1126083461.e1383050c23c0a9e2bea16b502bcf5e7@t eranews...
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


Nov 17 '05 #3

P: n/a
Hi,

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

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"aaj" <aa*@aaj.com> wrote in message
news:1126096839.8137b39231b1de5b7cc0c8ea06be2173@t eranews...
Hi

thanks for reply, and I agree entirely.

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

Andy
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:ew**************@TK2MSFTNGP12.phx.gbl...
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"aaj" <aa*@aaj.com> wrote in message
news:1126083461.e1383050c23c0a9e2bea16b502bcf5e7@t eranews...
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



Nov 17 '05 #4

P: n/a
aaj
Many thanks

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

thanks again

Andy

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:eI**************@TK2MSFTNGP09.phx.gbl...
Hi,

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

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"aaj" <aa*@aaj.com> wrote in message
news:1126096839.8137b39231b1de5b7cc0c8ea06be2173@t eranews...
Hi

thanks for reply, and I agree entirely.

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

Andy
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:ew**************@TK2MSFTNGP12.phx.gbl...
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"aaj" <aa*@aaj.com> wrote in message
news:1126083461.e1383050c23c0a9e2bea16b502bcf5e7@t eranews...
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



Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.