I have a WinForms app that I am trying to deploy with ClickOnce. It consists of an executable and a dependent dll, plus a bunch of loose xml files in a folder called "Map". The xml files all seem to be present and correct in the generated clickonce package and are all included in the .manifest file.
However, when I install and run, using the following code gives me a directory not found exception:
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
string mapPath = Path.Combine(appPath, "Maps");
foreach (string xmlFile in Directory.GetFiles(mapPath, "*.xml"))
when I look in "appPath" (which is C:\Users\Mark\AppData\Local\Apps\2.0\0H6ZLXXN.30V\3TNO49OJ.8JH\midi..tion_5194807c0e95e913_0000.0004_b9d52c73fd4d58ad\
), there is the app executable and dll, but the Maps folder is not there.
What am I doing wrong? Is this the correct way to be bundling extra files with my application? I would actually like the Maps folder to be somewhere the user can easily access and add their own files to anyway.
ok, I eventually found a code snippet that helped me out. The xml files were already being put into the ClickOnce "data directory" (this can be configured using the "application files" button on the publish tab of the project settings dialog. Then you can get at the data directory as follows:
private string GetDataDirectory()
{
if (ApplicationDeployment.IsNetworkDeployed)
{
return ApplicationDeployment.CurrentDeployment.DataDirectory;
}
else
{
return Application.StartupPath;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With