2014-09-02 68 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

相關問題