File.Exists对于不存在的文件返回true

Jua*_*uan 7 .net c# windows filesystems windows-vista

我的工作是保存在一个文件中的应用程序Path.GetDirectoryName(FilePath),其中FilePath = Application.ExecutablePath包含有关许可的一些信息.如果我从VS运行程序它可以正常工作,但如果我制作安装程序并安装然后运行它,程序会认为该文件已经存在.我改变了我的程序,以显示在消息框中我FilePath是否File.Exists(FilePath)返回truefalse.所以我查看了那条路径,启用了显示隐藏和系统文件,F5多次,没有.该文件不存在,但File.Exists(FilePath)返回true.知道为什么会发生这种感冒,我该如何解决呢?

我使用的是Windows Vista,Visual Studio 2010,C#,并使用VS的安装项目创建了我的安装程序.

编辑:我的路径是:C:\ Program Files(x86)\ Helium\License.xml.

这是我的代码的一部分:

        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
Run Code Online (Sandbox Code Playgroud)

忘了说我之前已经安装了应用程序,因此该文件曾经存在过.我使用控制面板卸载了.

ska*_*fes 22

如果要安装到系统文件夹,则可能会启动Windows文件虚拟化并创建每个用户的文件副本.因此,您的文件可能位于%userprofile%\ AppData\Local\VirtualStore文件夹中的某个位置