Доступ к файлу, отображенному в памяти, по пути запрещен.C#

Место общения программистов C#
Anonymous
Доступ к файлу, отображенному в памяти, по пути запрещен.

Сообщение Anonymous »

Я создаю файл с отображением в памяти:

Код: Выделить всё

 var security = new MemoryMappedFileSecurity();
security.SetAccessRule(new AccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MemoryMappedFileRights.FullControl, AccessControlType.Allow));

MemoryMappedFile memoryMappedFile = MemoryMappedFile.CreateFromFile(
new FileStream(path, FileMode.Open, FileAccess.Write, FileShare.ReadWrite),
"MMFName",
100000000,
MemoryMappedFileAccess.ReadWrite,
security,
HandleInheritability.None,
false
);
Несмотря на то, что после установки свойства безопасности и события после запуска в режиме администратора я все равно получаю ошибку «Доступ к пути запрещен»
Стек трассировка:

Код: Выделить всё

 at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore(SafeFileHandle fileHandle, String mapName, HandleInheritability inheritability, MemoryMappedFileSecurity memoryMappedFileSecurity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile(FileStream fileStream, String mapName, Int64 capacity, MemoryMappedFileAccess access, MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability inheritability, Boolean leaveOpen)
Попробовал MemoryMappedFileSecurity и попробовал запустить в режиме администратора.


Подробнее здесь: https://stackoverflow.com/questions/786 ... -is-denied

Вернуться в «C#»