当目录不存在时,Directory.Exists返回true

Bla*_*ell 8 .net c# windows-7

我正在开发一个Windows 7应用程序,并运行一些例程目录创建代码:

string dirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MyDir");    
if (!Directory.Exists(dirPath))
   Directory.CreateDirectory(dirPath);
Run Code Online (Sandbox Code Playgroud)

问题是,当我无法通过命令行和Windows资源管理器查看目录时,Directory.Exists行返回true.使用Windows XP时,这不是问题.Windows 7是否有一些我不知道的事情?

编辑:添加了Path.Combine

Lex*_* Li 11

请理解Windows Vista和Windows 7使用虚拟化来保护这些文件夹,因此您需要检查myDir是否在虚拟存储中,

C:\ Users(用户名)\ AppData\Local\VirtualStore\ProgramData