472,973 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,973 software developers and data experts.

adding files at compile time

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
5 4419
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
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


"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
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


"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Geoff Biggs | last post by:
Evening all, I'm trying to add a new built-in number data type to Python with its own syntax, so I'm working directly with the interpreter rather than creating my own extension module (side...
16
by: matthurne | last post by:
I just started learning C++ on my own...I'm using Accelerated C++. Something it hasn't explained and I keep wondering about is how header files actually work. I suspect it doesn't get into it...
2
by: Chien Lau | last post by:
I frequently define internal UserControl-derived classes in my WinForms apps: internal class MyUserControl:UserControl{ ... } I'll often need to embed these controls in a Form, whose class...
12
by: Wardeaux | last post by:
All, Wanting to find a way to create web pages to add to my website without having to recompile the codebehind everytime I want to add a new one... Here's the deal: I have a web app that takes...
2
by: Anna | last post by:
I added a small Web.Config file to the root of my website so that I could view errors on a machine other than the server: <configuration> <system.web> <customErrors mode="Off" /> </system.web>...
1
by: iwdu15 | last post by:
Hi, im making a freeware setup program. Im wondering if it is possible to add a resource (such as a file with information for the app to use) then compile the source code, all automatically? thanks...
9
by: xz | last post by:
What sense do h files make in c/cpp? I never thought about this question before. Does the existence of h files make sense at all? Why do we need to declare functions in h files and...
12
by: Jeff Gaines | last post by:
I am a hobbyist programmer, using C# and VS2008 and writing desktop apps. I am trying hard to take a modular approach to avoid re-inventing the wheel but I'm finding it a bit frustrating. For...
3
by: Robert Dunlop | last post by:
I am using Microsoft Visual Studio 2005 for development of an ASP.NET site, and I have a problem that greatly effects my workflow at times. It seems that after I upload new files anywhere within...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.