publish data files

SteveW

Member
Joined
Jul 11, 2006
Messages
6
Location
New Jersey
Programming Experience
Beginner
Followup Newbie Question

Besides the items mentioned (.NET, etc) I have several items that I need to have installed with my application when "setup.exe" runs. These include some .xml files and folders of images.

How can I get name them as prerequisites (or whatever might be needed) so they are installed along with the application? I've tried turning on the "Download prerequisites from the same location as my application" option in the PUBLISH/PREREQUISITES panel but this doesn't seem to do anything at all....

Thanks!

Steve...
 
Prereqs are special applications that need to be installed before the .Net application will start, it's not about common data files. You can add such files to the application resources, they will package and deploy with the application.
 
John,

Thanks for the help! I was able to add the two .xml files to the Resource list and they get copied (after setting the "Content" and "Copy always" property). But one problem remains.

I have a folder with over 500 thumbnails. How can I add it (the entire folder and not each thumbnail one-by-one)? The thumbnails change with nearly every release....

Also, to use the files, what path should I use in the code?

Steve...
 
Copy to file? Why, does other applications need access to these files, too?
If so you need to get a more advanced installer that allows such installation operations.

I was more thinking to leave them there and use them as resources. To add x number of files in one go, go first to Explorer and select them and Copy them (ctrl+c), then enter Project Properties, Resources tab and paste in there. It doesn't matter what resource file type is selected, when you paste in VS automatically detect the file type and add it to the appropriate file type section.

To use resource you can access with My.Resources... in code. Say, you added 'temp.bmp' to resources, you can get it right out like this:
VB.NET:
PictureBox1.Image = My.Resources.temp
You can also access a resource by string name like this:
VB.NET:
PictureBox1.Image = My.Resources.ResourceManager.GetObject("temp")

To find help just go to documentation and search the index by keyword 'resources', or MSDN online. All aspects are well described.
 
Hi John,

Well, I read all the documentation I could find. There is plenty on using strings and images as Resources but nothing on files. I'm using two XML files that hold data. Before trying to make them Resources, I was doing:

InputDS.ReadXml(File_Name + ".xml", XmlReadMode.ReadSchema)

and since I have the files at specific locations, this works fine.

Now, I've made the two XML files into Resources and I see they get carried along in the Resource folder after build/publish.

But I cannot find a way to access them from the InputDS.ReadXML method. Can you give me a clue on this?

This will still leave me with a problem for the images. There are over 500 of them in a folder. I tried making them all Resources and it took forever. I guess I can do this but it is a really ugly solution as the images are going to change on nearly every release. There is a separate program that compiles the list of images and puts them in a folder. Having to place each image individually as a Resource is going to be a nightmare for maintenance. Is there another way?

Thanks!

Steve...

 
SteveW said:
But I cannot find a way to access them from the InputDS.ReadXML method. Can you give me a clue on this?
Yes, but the XmlReadMode.ReadSchema will not work since inline schema instruction points to relative file. What you do is first read the Schema into dataset (I guess that is what you insinuate with the inputDS variable name), then read the Xml. Code is like this:
VB.NET:
Dim sr As IO.StringReader
sr = New IO.StringReader(My.Resources.myschema)
inputDS.ReadXmlSchema(sr)
sr = New IO.StringReader(My.Resources.myxml)
inputDS.ReadXml(sr)
sr.Close()
 
'or get resource by name:
'sr = New IO.StringReader(My.Resources.ResourceManager.GetString("myxml"))
This will still leave me with a problem for the images. There are over 500 of them in a folder. I tried making them all Resources and it took forever. I guess I can do this but it is a really ugly solution as the images are going to change on nearly every release. There is a separate program that compiles the list of images and puts them in a folder. Having to place each image individually as a Resource is going to be a nightmare for maintenance.
You did one copy operation on all files, went to resources and did one paste operation, then you had to wait forever for finishing up? I actually tried with a collection of 900 images, adding them all in one go took only 10 seconds. As for file changes, the resources are linked at compile time, so if the actual file changes this will be reflected in last build. You can see this in detail view of resources that displays file path and size also, try changing the content of one file in filesystem and the size updates immediately in res-view also. If you mean filenames change, new, removed etc then it's best to go to resources Select All and Delete, then re-add and wait forever. I don't know what you mean when you say "Having to place each image individually".

Is there another way?
I know no other way with ClickOnce. VS Professional got the MSI setup that is more advanced. There are some standalone installers out there too, AdvancedInstaller for instance http://www.advancedinstaller.com/ looks like the free edition allows file and folder hierarchies.
 
Back
Top