public static void AssemblyInitialize(TestContext context) { var dokanOptions = DokanOptions.DebugMode | DokanOptions.MountManager | DokanOptions.CurrentSession; #if NETWORK_DRIVE dokanOptions |= DokanOptions.NetworkDrive; #else dokanOptions |= DokanOptions.RemovableDrive; #endif #if USER_MODE_LOCK dokanOptions |= DokanOptions.UserModeLock; #endif Dokan.Init(); safeMount = DokanOperationsFixture.Operations.CreateFileSystem(DokanOperationsFixture.NormalMountPoint, dokanOptions); unsafeMount = DokanOperationsFixture.UnsafeOperations.CreateFileSystem(DokanOperationsFixture.UnsafeMountPoint, dokanOptions); var drive = new DriveInfo(DokanOperationsFixture.NormalMountPoint); var drive2 = new DriveInfo(DokanOperationsFixture.UnsafeMountPoint); while (!drive.IsReady || !drive2.IsReady) { Thread.Sleep(50); } while (DokanOperationsFixture.HasPendingFiles) { Thread.Sleep(50); } }
public void Start(string mirrorPath, string mountPath, DokanInstance dokanInstance) { sourcePath = mirrorPath; targetPath = mountPath; dokanCurrentInstance = dokanInstance; commonFsWatcher = new FileSystemWatcher(mirrorPath) { IncludeSubdirectories = true, NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size }; commonFsWatcher.Changed += OnCommonFileSystemWatcherChanged; commonFsWatcher.Created += OnCommonFileSystemWatcherCreated; commonFsWatcher.Renamed += OnCommonFileSystemWatcherRenamed; commonFsWatcher.EnableRaisingEvents = true; fileFsWatcher = new FileSystemWatcher(mirrorPath) { IncludeSubdirectories = true, NotifyFilter = NotifyFilters.FileName }; fileFsWatcher.Deleted += OnCommonFileSystemWatcherFileDeleted; fileFsWatcher.EnableRaisingEvents = true; dirFsWatcher = new FileSystemWatcher(mirrorPath) { IncludeSubdirectories = true, NotifyFilter = NotifyFilters.DirectoryName }; dirFsWatcher.Deleted += OnCommonFileSystemWatcherDirectoryDeleted; dirFsWatcher.EnableRaisingEvents = true; }
private static void Main(string[] args) { try { var arguments = args .Select(x => x.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)) .ToDictionary(x => x[0], x => x.Length > 1 ? x[1] as object : true, StringComparer.OrdinalIgnoreCase); var mirrorPath = arguments.ContainsKey(MirrorKey) ? arguments[MirrorKey] as string : @"C:\"; var mountPath = arguments.ContainsKey(MountKey) ? arguments[MountKey] as string : @"N:\"; var unsafeReadWrite = arguments.ContainsKey(UseUnsafeKey); Console.WriteLine($"Using unsafe methods: {unsafeReadWrite}"); var mirror = unsafeReadWrite ? new UnsafeMirror(mirrorPath) : new Mirror(mirrorPath); Dokan.Init(); using (DokanInstance dokanInstance = mirror.CreateFileSystem(mountPath, DokanOptions.DebugMode | DokanOptions.EnableNotificationAPI)) { var notify = new Notify(); notify.Start(mirrorPath, mountPath, dokanInstance); dokanInstance.WaitForFileSystemClosed(uint.MaxValue); } Dokan.Shutdown(); Console.WriteLine(@"Success"); } catch (DokanException ex) { Console.WriteLine(@"Error: " + ex.Message); } }