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

adding files at compile time

P: n/a
I have a situation, where I need to add 4 or 5 data files (they change
every time I build) in my project during build time and somehow I need
a way to access these files during runtime.
So I have 2 questions
1. Is it possible to identify all the files in the resource file
during runtime by name of the file?
2. Is it possible to add files to a project at build time to make an
exe with those files?
Thanks.
Mar 5 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You can add them to your project, set Build Action to "Content" and the
"Copy to Output Dir" to "Copy Always". Then you can load it by its relative
path to the ApplicationPath.

Or you can add them as an embedded resource.

Is that what you mean? You just want to include them and then access them?

RobinS.
GoldMail, Inc.
--------------------------
"DBC User" <db*****@gmail.comwrote in message
news:de**********************************@u72g2000 hsf.googlegroups.com...
>I have a situation, where I need to add 4 or 5 data files (they change
every time I build) in my project during build time and somehow I need
a way to access these files during runtime.
So I have 2 questions
1. Is it possible to identify all the files in the resource file
during runtime by name of the file?
2. Is it possible to add files to a project at build time to make an
exe with those files?
Thanks.
Mar 6 '08 #2

P: n/a
On Mar 5, 11:44*pm, "RobinS" <rob...@imnottelling.comwrote:
You can add them to your project, set Build Action to "Content" and the
"Copy to Output Dir" to "Copy Always". Then you can load it by its relative
path to the ApplicationPath.

Or you can add them as an embedded resource.

Is that what you mean? You just want to include them and then access them?

RobinS.
GoldMail, Inc.
--------------------------"DBC User" <dbcu...@gmail.comwrote in message

news:de**********************************@u72g2000 hsf.googlegroups.com...
I have a situation, where I need to add 4 or 5 data files (they change
every time I build) in my project during build time and somehow I need
a way to access these files during runtime.
So I have 2 questions
1. Is it possible to identify all the files in the resource file
during runtime by name of the file?
2. Is it possible to add files to a project at build time to make an
exe with those files?
Thanks.- Hide quoted text -

- Show quoted text -
I would like to add them as embedded resource. This is what I found so
far, I could write a seperate program which will generate the resource
file with all the required files and then build the new program which
need to access it with the new resource. So I would like to find a way
to add the text files to resource file and way to read it back.
Thanks.
Mar 6 '08 #3

P: n/a


"DBC User" wrote:
On Mar 5, 11:44 pm, "RobinS" <rob...@imnottelling.comwrote:
You can add them to your project, set Build Action to "Content" and the
"Copy to Output Dir" to "Copy Always". Then you can load it by its relative
path to the ApplicationPath.

Or you can add them as an embedded resource.

Is that what you mean? You just want to include them and then access them?

RobinS.
GoldMail, Inc.
--------------------------"DBC User" <dbcu...@gmail.comwrote in message

news:de**********************************@u72g2000 hsf.googlegroups.com...
>I have a situation, where I need to add 4 or 5 data files (they change
every time I build) in my project during build time and somehow I need
a way to access these files during runtime.
So I have 2 questions
1. Is it possible to identify all the files in the resource file
during runtime by name of the file?
2. Is it possible to add files to a project at build time to make an
exe with those files?
Thanks.- Hide quoted text -
- Show quoted text -

I would like to add them as embedded resource. This is what I found so
far, I could write a seperate program which will generate the resource
file with all the required files and then build the new program which
need to access it with the new resource. So I would like to find a way
to add the text files to resource file and way to read it back.
Thanks.
Then set the "Build Action" to "Embedded Resource". Do you mean the
filenames change every build or the file contents change every build?
>
Mar 6 '08 #4

P: n/a
On Mar 6, 11:27*am, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
"DBC User" wrote:
On Mar 5, 11:44 pm, "RobinS" <rob...@imnottelling.comwrote:
You can add them to your project, set Build Action to "Content" and the
"Copy to Output Dir" to "Copy Always". Then you can load it by its relative
path to the ApplicationPath.
Or you can add them as an embedded resource.
Is that what you mean? You just want to include them and then access them?
RobinS.
GoldMail, Inc.
--------------------------"DBC User" <dbcu...@gmail.comwrote in message
>news:de**********************************@u72g200 0hsf.googlegroups.com....
I have a situation, where I need to add 4 or 5 data files (they change
every time I build) in my project during build time and somehow I need
a way to access these files during runtime.
So I have 2 questions
1. Is it possible to identify all the files in the resource file
during runtime by name of the file?
2. Is it possible to add files to a project at build time to make an
exe with those files?
Thanks.- Hide quoted text -
- Show quoted text -
I would like to add them as embedded resource. This is what I found so
far, I could write a seperate program which will generate the resource
file with all the required files and then build the new program which
need to access it with the new resource. So I would like to find a way
to add the text files to resource file and way to read it back.
Thanks.

Then set the "Build Action" to "Embedded Resource". *Do you mean the
filenames change every build or the file contents change every build? *

Yes that is correct. So here is what I am planning to do
1. All the input files required will be staged in a temp folder for
me. So I will have one program which will read each file and create a
console c# program to add it to a resource file. This step only
creates an output c# program.
2. Now I run command line compiler to build and then run the program.
The output will be a resource file.
3. Now build my actual program which expects all the files in resource
file to run at the destination with the resource file created at step
2.
4. Copy the final exe to destination server and run it.

I got al step 2, 3 and 4 except the part where how to add a file to a
resource file and read a file from resource file. All the example I
have seen so far are image files. I couldn't find single example for
adding a text/binary file to a resource file.

So if someone can help me on how to write a text file to resource file
and read the text file back from resource file, it would be greatful.

Thanks again.
Mar 7 '08 #5

P: n/a


"DBC User" wrote:
On Mar 6, 11:27 am, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
"DBC User" wrote:
On Mar 5, 11:44 pm, "RobinS" <rob...@imnottelling.comwrote:
You can add them to your project, set Build Action to "Content" and the
"Copy to Output Dir" to "Copy Always". Then you can load it by its relative
path to the ApplicationPath.
Or you can add them as an embedded resource.
Is that what you mean? You just want to include them and then access them?
RobinS.
GoldMail, Inc.
--------------------------"DBC User" <dbcu...@gmail.comwrote in message
news:de**********************************@u72g2000 hsf.googlegroups.com....
>I have a situation, where I need to add 4 or 5 data files (they change
every time I build) in my project during build time and somehow I need
a way to access these files during runtime.
So I have 2 questions
1. Is it possible to identify all the files in the resource file
during runtime by name of the file?
2. Is it possible to add files to a project at build time to make an
exe with those files?
Thanks.- Hide quoted text -
- Show quoted text -
I would like to add them as embedded resource. This is what I found so
far, I could write a seperate program which will generate the resource
file with all the required files and then build the new program which
need to access it with the new resource. So I would like to find a way
to add the text files to resource file and way to read it back.
Thanks.
Then set the "Build Action" to "Embedded Resource". Do you mean the
filenames change every build or the file contents change every build?
Yes that is correct. So here is what I am planning to do
1. All the input files required will be staged in a temp folder for
me. So I will have one program which will read each file and create a
console c# program to add it to a resource file. This step only
creates an output c# program.
2. Now I run command line compiler to build and then run the program.
The output will be a resource file.
3. Now build my actual program which expects all the files in resource
file to run at the destination with the resource file created at step
2.
4. Copy the final exe to destination server and run it.

I got al step 2, 3 and 4 except the part where how to add a file to a
resource file and read a file from resource file. All the example I
have seen so far are image files. I couldn't find single example for
adding a text/binary file to a resource file.

So if someone can help me on how to write a text file to resource file
and read the text file back from resource file, it would be greatful.

Thanks again.
The process for adding the files as a resource should be the same whether
the file is a bitmap/jpeg/tiff or the text of "War and Peace". You get the
files out at runtime with GetManifestResourceStream and read it with a
StreamReader, rather than sending it to the constructor for an image.
Mar 7 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.