Saving file to target using ClickOnce

P

Peter Webb

My app running on my machine stores and loads data from c:\temp just fine. I
want to distribute the software with these files loaded into some target
directory - I don't care if its isolated storage, the default application
directory, whatever.

The VS2005 EE documentation says something about using some tool called
mage.exe or mageui.exe to package my files into the distribution. There are
at least two problems with that:

1. I can't find mage.exe, maybe because I am running the frEE edition.

2. The instructions are largely complete gobbledly-gook to me, and none of
it is hyperlinked. I don't know what/how updating an application manifest
is, how to generate a key pair, or anything about modifying hash keys.

I have 600k of data I need to store when the app is either installed, or the
first time its run.

Where I am at the moment is that the best I can come up with is that I write
a little program to turn my 600k of xml data files into 1.2Mb of ascii hex
characters and cut and paste this as a string constant into my source code.
When the program is run, it checks if the files exist and if they don't then
it converts the ascii hex string back into ascii xml and writes it to disk.

I am of course aware that this is completely brain-dead, but I know I can
knock it together in an hour or two. Any easier solutions would be most
welcome.
 
N

Nicholas Paldino [.NET/C# MVP]

Peter,

You state:

I have 600k of data I need to store when the app is either installed, or the
first time its run.

If that is the case, create a resource file, add your data file to the
resource file, and then check for the existence of the file in the temp
directory (you can't assume c:\temp is the temp directory, rather, you need
to call the static GetFolderPath method on the Environment class to get the
temp directory for the current user, or use Isolated Storage).

If the file doesn't exist, then create the file. Read the file from the
resources (the designer should have created a managed wrapper and exposed it
for you as a stream).

Or, to make it even easier, you can add the file to the project, and set
the build action to "Embedded Resource" and then call the
GetManifestResourceStream method on the Assembly that contains it (usually
the running assembly, for which you can call the static GetExecutingAssembly
method from code in that assembly to get the reference). This will return a
stream which you can just read the contents from and write to the
appropriate file when needed.
 

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