PROBLEM #1:
I have a program that accesses several XML files that are located in a subfolder called "xmlfiles." This folder is a subfolder in my project.
I am using "Application.Settings" to store the locations of the XML files. For example, I have an entry for "JobsXML" that has a string with the file path of the XML file to load.
To get these files to load, I had to use relative references: The path settings for "JobsXML" is "..\..\..\xmlfiles\jobs.xml"
I have to go up 3 directories because the files are in "\debug\bin" during design. This will not be the case at runtime.
This arrangement works fine in the editor, but when I make a "ClickOnce" package, the relative path will no longer work for installed applications. The directory will be different.
How can I setup my code so that the "xmlfiles" subfolder will be correctly used at runtime? I need to be able to run this from my project folder under "My Documents/Visual Studio 2005/Projects/etc..." and also, I need it to work from the runtime directory that the user installs the program to.
So if the user installs the package to "C:\temp\" then the code should use the setting for "JobsXML" by going to "C:\temp\xmlfiles\jobs.xml."
PROBLEM #2:
There is an attribute in some of my XML files that is also, a relative file reference.
I have another subfolder called "images" that also resides in my project. This folder contains images that are loaded at runtime.
In my XML file, each node has an attribute, "filepath" that has a value of "..\..\..\images\filename.jpg"
I also need to be able to access this relatively, just like the XMLfiles I mentioned in PROBLEM #1.
I have tried different combinations of StartupPath, Path.Combine and a few others...with no success. I am new to this so I could use some sample code to put this together correctly.
Thanks
I have a program that accesses several XML files that are located in a subfolder called "xmlfiles." This folder is a subfolder in my project.
I am using "Application.Settings" to store the locations of the XML files. For example, I have an entry for "JobsXML" that has a string with the file path of the XML file to load.
To get these files to load, I had to use relative references: The path settings for "JobsXML" is "..\..\..\xmlfiles\jobs.xml"
I have to go up 3 directories because the files are in "\debug\bin" during design. This will not be the case at runtime.
This arrangement works fine in the editor, but when I make a "ClickOnce" package, the relative path will no longer work for installed applications. The directory will be different.
How can I setup my code so that the "xmlfiles" subfolder will be correctly used at runtime? I need to be able to run this from my project folder under "My Documents/Visual Studio 2005/Projects/etc..." and also, I need it to work from the runtime directory that the user installs the program to.
So if the user installs the package to "C:\temp\" then the code should use the setting for "JobsXML" by going to "C:\temp\xmlfiles\jobs.xml."
PROBLEM #2:
There is an attribute in some of my XML files that is also, a relative file reference.
I have another subfolder called "images" that also resides in my project. This folder contains images that are loaded at runtime.
In my XML file, each node has an attribute, "filepath" that has a value of "..\..\..\images\filename.jpg"
I also need to be able to access this relatively, just like the XMLfiles I mentioned in PROBLEM #1.
I have tried different combinations of StartupPath, Path.Combine and a few others...with no success. I am new to this so I could use some sample code to put this together correctly.
Thanks
Last edited: