2014-09-02 60 views
6

我正在打开系统卷信息子文件夹中的内存映射文件。我知道并在资源管理器中看到它存在那里,并且路径是正确的(它是从资源管理器复制粘贴的),此外,该路径的File.Exists返回true,但MemoryMappedFile.OpenExisting失败并显示DirectoryNotFoundException。为什么? (我拥有系统卷信息文件夹和子文件夹的所有权利)。File.Exists返回true,并且OpenExisting失败,出现DirectoryNotFoundException

一些代码:

const string filePath = @"C:\\System Volume Information\\Foo\\2.ext"; 

bool exists = File.Exists(filePath); //is true 
using (MemoryMappedFile bitmapFile = MemoryMappedFile.OpenExisting(filePath, MemoryMappedFileRights.Read)) //Throws DirectoryNotFoundException 
{ 
    ... 
} 

回答

1

我还没有使用这些API,但我相信你需要首先将文件映射到内存中。尝试MemoryMappedFile.CreateFromFile

相关问题