I'm working on an app that saves a file in Path.GetDirectoryName(FilePath)
where FilePath = Application.ExecutablePath
that contains some information about licensing. If I run the program from VS it works OK but if I make an installer and install and then run it, the program thinks that the file already exists. I changed my program to show on a message box my FilePath
and whether File.Exists(FilePath)
returns true
or false
. So I looked in that path, enabled showing hidden and system files, F5'd several times and nothing. The file doesn't exist, but File.Exists(FilePath)
returns true. Any idea why cold this be happening and how can I work around it?
I'm using Windows Vista, Visual Studio 2010, C# and created my installer with VS's Setup Project.
Edit: My path is: C:\Program Files (x86)\Helium\License.xml.
This is part of my code:
MessageBox.Show("LicenseFileName: " + LicenseFileName); // LicenseFileName: C:\Program Files (x86)\Helium\License.xml
System.Diagnostics.Process.Start(LicenseFileName); // Nothing happens
MessageBox.Show("File.Exists(LicenseFileName): " + File.Exists(LicenseFileName)); // File.Exists(LicenseFileName): true
Forgot to say that I already had the application installed before so the file used to exist. I uninstalled using Control Panel.
If you are installing to a system folder, it is possible that Windows file virtualization kicked in and created a per user copy of the files. So your files may be located somewhere in %userprofile%\AppData\Local\VirtualStore folder
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