Использую DokanNet и Dokany для создания виртуального диска.
Шкурка, которая ничего не делает, на Win10 работает, но на Win7 завершается в течение минуты после запуска с ошибкой. Проверял только на двух компах, поэтому не могу гарантировать, что связано с версией ОС. Возможно, проблема связана с чем-то другим. В свойствах проекта выставлен .net framework 4.5.2.
Стандартный пример RegistryFS
ведёт себя так же (если поменять его зависимость на версию DokanNet.net4.0). Версия под 4.6 вообще не компилируется.
На всякий случай, вот мой несколько изменённый и подчищенный код:
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Security.AccessControl;
using DokanNet;
using Microsoft.Win32;
using FileAccess = DokanNet.FileAccess;
using System.Diagnostics;
using System.Reflection;
namespace PackAllStreams
{
internal class MyDokanImpl : IDokanOperations
{
#region DokanOperations member
public MyDokanImpl()
{
}
public void Cleanup(string filename, DokanFileInfo info)
{
}
public void CloseFile(string filename, DokanFileInfo info)
{
}
public NtStatus CreateFile(
string filename,
FileAccess access,
FileShare share,
FileMode mode,
FileOptions options,
FileAttributes attributes,
DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus DeleteDirectory(string filename, DokanFileInfo info)
{
return DokanResult.Error;
}
public NtStatus DeleteFile(string filename, DokanFileInfo info)
{
return DokanResult.Error;
}
public NtStatus FlushFileBuffers(
string filename,
DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus FindFiles(
string filename,
out IList<FileInformation> files,
DokanFileInfo info)
{
files = new List<FileInformation>();
return DokanResult.Success;
}
public NtStatus GetFileInformation(
string filename,
out FileInformation fileinfo,
DokanFileInfo info)
{
fileinfo = new FileInformation { FileName = filename };
fileinfo.Attributes = FileAttributes.Directory;
fileinfo.LastAccessTime = DateTime.Now;
fileinfo.LastWriteTime = null;
fileinfo.CreationTime = null;
return DokanResult.Success;
}
public NtStatus LockFile(
string filename,
long offset,
long length,
DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus MoveFile(
string filename,
string newname,
bool replace,
DokanFileInfo info)
{
return DokanResult.Error;
}
public NtStatus ReadFile(
string filename,
byte[] buffer,
out int readBytes,
long offset,
DokanFileInfo info)
{
readBytes = 0;
return DokanResult.Success;
}
public NtStatus SetEndOfFile(string filename, long length, DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus SetAllocationSize(string filename, long length, DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus SetFileAttributes(
string filename,
FileAttributes attr,
DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus SetFileTime(
string filename,
DateTime? ctime,
DateTime? atime,
DateTime? mtime,
DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus UnlockFile(string filename, long offset, long length, DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus Mounted(DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus Unmounted(DokanFileInfo info)
{
return DokanResult.Success;
}
public NtStatus GetDiskFreeSpace(
out long freeBytesAvailable,
out long totalBytes,
out long totalFreeBytes,
DokanFileInfo info)
{
freeBytesAvailable = 512 * 1024 * 1024 * 1024L;
totalBytes = 1024 * 1024 * 1024 * 1024L;
totalFreeBytes = 512 * 1024 * 1024 * 1024L;
return DokanResult.Success;
}
public NtStatus WriteFile(
string filename,
byte[] buffer,
out int writtenBytes,
long offset,
DokanFileInfo info)
{
writtenBytes = buffer.Length;
return DokanResult.Success;
}
public NtStatus GetVolumeInformation(out string volumeLabel, out FileSystemFeatures features,
out string fileSystemName, DokanFileInfo info)
{
volumeLabel = "MyDokanImpl";
features = FileSystemFeatures.None;
fileSystemName = string.Empty;
return DokanResult.Error;
}
public NtStatus GetFileSecurity(string fileName, out FileSystemSecurity security, AccessControlSections sections,
DokanFileInfo info)
{
security = null;
return DokanResult.Error;
}
public NtStatus SetFileSecurity(string filename, FileSystemSecurity security, AccessControlSections sections,
DokanFileInfo info)
{
return DokanResult.Error;
}
public NtStatus EnumerateNamedStreams(string filename, IntPtr enumContext, out string streamName,
out long streamSize, DokanFileInfo info)
{
streamName = string.Empty;
streamSize = 0;
return DokanResult.NotImplemented;
}
public NtStatus FindStreams(string filename, out IList<FileInformation> streams, DokanFileInfo info)
{
streams = new FileInformation[0];
return DokanResult.Success;
}
public NtStatus FindFilesWithPattern(string filename, string searchPattern, out IList<FileInformation> files,
DokanFileInfo info)
{
files = new FileInformation[0];
return DokanResult.Success;
}
#endregion DokanOperations member
}
internal class Program
{
private static void Main()
{
Directory.CreateDirectory("Output");
try
{
var rfs = new MyDokanImpl();
rfs.Mount(@"r:\", DokanOptions.DebugMode | DokanOptions.StderrOutput);
Console.WriteLine("Success");
}
catch (DokanException ex)
{
Console.WriteLine("Error: " + ex);
}
}
}
}
Строки, предшествующие завершению с ошибкой (mounted появляется после запуска, потом тишина, потом ошибки про запись):
mounted: r:\ -> \Volume{d6cc17c5-1739-4085-bce7-964f1e9f5de9}
###Create 0003
CreateFile status = 0
###QueryVolumeInfo -001
###GetFileInfo 0003
###Create 0004
CreateFile status = 0
result = 0
###Create 0004
CreateFile status = 0
FileStandardInformation
DispatchQueryInformation result = 0
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1739-4085-bce7-964f1e9f5de9}: 2
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1739-4085-bce7-964f1e9f5de9}: 2
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1739-4085-bce7-964f1e9f5de9}: 2
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1739-4085-bce7-964f1e9f5de9}: 2
Dokan Error: DokanKeepAlive CreateFile failed \\.\Volume{d6cc17c5-1739-4085-bce7-964f1e9f5de9}: 2
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1739-4085-bce7-964f1e9f5de9}: 2
unload
Success
Обращаю внимание на строку Success
- т. е. в приложении исключение не возникало, дик по некой причине был размонтирован.
Как можно исправить эту проблему?
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Нужно опубликовать сайт на сервере где стоит линукс так как деплоинг сайта на виндовс стоит очень дорогоКакое програмное обеспечение нужно...