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)HeliumLicense.xml.
This is part of my code:
MessageBox.Show("LicenseFileName: " + LicenseFileName); // LicenseFileName: C:Program Files (x86)HeliumLicense.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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…