コード例 #1
0
ファイル: Program.cs プロジェクト: ycherkes/MountSqlBackup
        private static void Main(string[] args)
        {
            try
            {
                if (args.Length != 2)
                {
                    Console.WriteLine(@"usage: mountbck.exe S 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup\AdventureWorks2014.bak'");
                    Console.WriteLine("Press any key for exit.");
                    Console.ReadKey();
                    return;
                }

                var driveLetter    = args[0][0];
                var backupFileName = args[1];

                Dokan.Unmount(driveLetter);
                var backupVfs = new SqlBackupVfs(backupFileName, driveLetter);
                backupVfs.Mount($"{driveLetter}:\\", DokanOptions.NetworkDrive, 1);

                Console.WriteLine("Success");
            }
            catch (DokanException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
コード例 #2
0
        private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e)
        {
            Log.Information("Device disconnected", e.Device);
            List <VirtualDrive> drivesToRemove = new List <VirtualDrive>();

            foreach (VirtualDrive d in Devices)
            {
                if (e.Device.Serial.Equals(d.AndroidDevice.Serial))
                {
                    if (Dokan.Unmount(d.DriveLetter))
                    {
                        Log.Information("Successfully unmounted drive " + d.DriveLetter);
                    }
                    else
                    {
                        Log.Warning("Error while unmounting " + d.DriveLetter);
                    }
                    drivesToRemove.Add(d);
                }
            }
            foreach (VirtualDrive d in drivesToRemove)
            {
                Devices.Remove(d);
            }
        }
コード例 #3
0
ファイル: MgmtPanel.cs プロジェクト: acdra1n/megafuse
 private void unmountBtn_Click(object sender, EventArgs e)
 {
     unmountBtn.Enabled = false;
     SetFUSEStatus("Unmounting...", Color.Orange);
     Dokan.Unmount(DriveLetter);
     SetFUSEStatus("Unmounted.", Color.Red);
 }
コード例 #4
0
        public static void Unmount(MountableFileSystem fs)
        {
            Dokan.Unmount(Mounted[fs].Item2);
            string mountPoint = $"{Mounted[fs].Item2}:";

            Mounted[fs].Item1.Join(); // wait for thread to actually stop
            Dokan.RemoveMountPoint(mountPoint);
        }
コード例 #5
0
 public static void AssemblyCleanup()
 {
     mounterThread.Abort();
     mounterThread2.Abort();
     Dokan.Unmount(DokanOperationsFixture.NormalMountPoint[0]);
     Dokan.Unmount(DokanOperationsFixture.UnsafeMountPoint[0]);
     Dokan.RemoveMountPoint(DokanOperationsFixture.NormalMountPoint);
     Dokan.RemoveMountPoint(DokanOperationsFixture.UnsafeMountPoint);
 }
コード例 #6
0
        public bool UnMountVirtualDrive()
        {
            if (_mountPoint == null)
            {
                return(false);
            }

            return(Dokan.Unmount(_mountPoint[0]) && Dokan.RemoveMountPoint(_mountPoint));
        }
コード例 #7
0
ファイル: VirtualDrive.cs プロジェクト: KarpelesLab/drive-win
        public void Unmount()
        {
            if (_th != null)
            {
                _th.Abort();
            }

            Dokan.Unmount(this.DriveLetter);
            Dokan.RemoveMountPoint(this.DriveLetter + ":");
        }
コード例 #8
0
        public static void startVDrive(char vDriveLetter)
        {
            Dokan.Unmount(vDriveLetter);
            di = new VDrive();
#if DEBUG
            Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.DebugMode, 1); });
#else
            Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.FixedDrive, 10); });
#endif
            t2.Start();
        }
コード例 #9
0
ファイル: frmMain.cs プロジェクト: vidarw/RVWorld
        private void startVDriveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Dokan.Unmount(vDriveLetter);
            di = new VDrive();
#if DEBUG
            Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.DebugMode, 1); });
#else
            Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.FixedDrive, 10); });
#endif
            t2.Start();
        }
コード例 #10
0
        private void OnClosing(object sender, CancelEventArgs e)
        {
            if (unmountingPhase != UnmountingPhase.NotInitiated)
            {
                if (unmountingPhase == UnmountingPhase.Initiated)
                {
                    e.Cancel = true;
                }

                return;
            }

            try
            {
                fs.Save();

                if (Dokan.Unmount(DRIVE_LETTER))
                {
                    e.Cancel        = true;
                    unmountingPhase = UnmountingPhase.Initiated;

                    pathRow.Opacity      = 0;
                    messageRow.Text      = "Unmounting...";
                    saveButton.Opacity   = 0;
                    saveButton.IsEnabled = false;
                }

                else
                {
                    throw new IOException("Unmount error");
                }
            }

            catch (WrappedFileException ef)
            {
                if (MessageBox.Show("Some files were not successfully converted and retained unmodified. "
                                    + "If you close this application now, you will lose any changes made to these 'faulted' files.\n\n"
                                    + ef.MessageBoxText + "\n\nDo you want to close the app?", "Warning",
                                    MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) != MessageBoxResult.Yes)
                {
                    e.Cancel = true;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Due to some reason, unmounting wasn't successful.\n\n"
                                + ex.GetType().ToString() + ": " + ex.Message + "\n\n"
                                + "The application will be TERMINATED right after the OK button is pressed.\n\nBye.", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(-1);
            }
        }
コード例 #11
0
 public static void End()
 {
     try
     {
         Dokan.Unmount(Properties.Settings.Default.MountPoint[0]);
         Dokan.RemoveMountPoint(Properties.Settings.Default.MountPoint + ":\\");
     }
     catch (Exception)
     {
         // ignored
     }
 }
コード例 #12
0
 public static void UnmountAll()
 {
     foreach (Tuple <Thread, char> fs in Mounted.Values)
     {
         Dokan.Unmount(fs.Item2); // tell every drive to unmount
     }
     foreach (Tuple <Thread, char> fs in new List <Tuple <Thread, char> >(Mounted.Values))
     {
         fs.Item1.Join(); // wait for thread to stop (wait for drives to be unmounted)
     }
     Mounted.Clear();
 }
コード例 #13
0
 /// <summary>
 /// Unmount the main volume - not used in current implementation
 /// </summary>
 public void UnmountMainVolume()
 {
     if (_mainMounted)
     {
         char driveLetter = fsOp.Drive.ToCharArray()[0];
         Console.WriteLine("Unmounting main volume from '" + driveLetter + "'");
         Dokan.Unmount(driveLetter);
     }
     else
     {
         throw new VolumeMountManagerException("Main volume can only be unmounted if it was mounted before.");
     }
 }
コード例 #14
0
        private static void Unmount(this Settings settings)
        {
            try
            {
                Dokan.Unmount(mountpoint);

                Console.WriteLine($"Unmounted {mountpoint}:\\");
            }
            catch
            {
            }
            finally
            {
                if (regkey != null)
                {
                    try
                    {
                        regkey.Close();

                        Registry.LocalMachine.OpenSubKey(REG_BASE).DeleteSubKeyTree($"{mountpoint}", false);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        regkey.Dispose();
                        regkey = null;
                    }
                }

                if (settings.DeleteCache && (filesys != null))
                {
                    try
                    {
                        if (filesys.TemporaryDirectory.Exists)
                        {
                            filesys.TemporaryDirectory.Delete(true);
                        }
                    }
                    catch
                    {
                    }
                }

                filesys = null;

                OnExit();
            }
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: zhang024/DokanCloudFS
        internal static void Main(string[] args)
        {
            var mountSection = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Sections[MountSection.Name] as MountSection;

            if (mountSection == null)
            {
                throw new ConfigurationErrorsException("Mount configuration missing");
            }

            CompositionInitializer.Preload(typeof(IgorSoft.CloudFS.Interface.Composition.ICloudGateway));
            CompositionInitializer.Initialize(mountSection.LibPath, "IgorSoft.CloudFS.Gateways.*.dll");
            var factory = new CloudDriveFactory();

            CompositionInitializer.SatisfyImports(factory);

            try {
                var logger = new LogFactory().GetCurrentClassLogger();
                using (var tokenSource = new CancellationTokenSource()) {
                    var tasks = new List <Task>();
                    foreach (var drive in mountSection.Drives.Cast <DriveElement>())
                    {
                        var operations = new CloudOperations(factory.CreateCloudDrive(drive.Schema, drive.UserName, drive.Root, new CloudDriveParameters()
                        {
                            EncryptionKey = drive.EncryptionKey, Parameters = drive.GetParameters()
                        }), logger);

                        // HACK: handle non-unique parameter set of DokanOperations.Mount() by explicitely specifying AllocationUnitSize and SectorSize
                        tasks.Add(Task.Run(() => operations.Mount(drive.Root, DokanOptions.RemovableDrive | DokanOptions.MountManager | DokanOptions.CurrentSession, mountSection.Threads, 1100, TimeSpan.FromSeconds(drive.Timeout != 0 ? drive.Timeout : 20), null, 512, 512), tokenSource.Token));

                        var driveInfo = new DriveInfo(drive.Root);
                        while (!driveInfo.IsReady)
                        {
                            Thread.Sleep(10);
                        }
                    }

                    Console.ReadKey(true);

                    tokenSource.Cancel();
                }
            } finally {
                foreach (var drive in mountSection.Drives.Cast <DriveElement>())
                {
                    Dokan.Unmount(drive.Root[0]);
                }
            }
        }
コード例 #16
0
ファイル: VirtualDrive.cs プロジェクト: morristech/BeSafe
        public bool UnmapDrive(string driveLetter)
        {
            if (string.IsNullOrEmpty(driveLetter))
            {
                throw new ArgumentNullException(nameof(driveLetter));
            }

            try
            {
                Dokan.Unmount(driveLetter[0]);
                return(true);
            }
            catch (Exception ex)
            {
                ex.Log(ExceptionType.SecureVolume, @"Can not unmount virtual drive");
                return(false);
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: ycherkes/MountSqlBackup
        private static void Main()
        {
            try
            {
                var driveLetter    = 'S';
                var backupFileName = @"C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup\AdventureWorks2014.bak";

                Dokan.Unmount(driveLetter);
                var backupVfs = new SqlBackupVfs(backupFileName, driveLetter);
                backupVfs.Mount($"{driveLetter}:\\", DokanOptions.NetworkDrive, 1);

                Console.WriteLine("Success");
            }
            catch (DokanException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
コード例 #18
0
ファイル: BuildFsFileSystem.cs プロジェクト: tronsoft/BuildFs
        public static BuildFsFileSystem Mount(char letter, DokanOptions options)
        {
            Dokan.Unmount(letter);

            var fs = new BuildFsFileSystem();

            fs.Letter = letter;
            var t = Task.Run(() => Dokan.Mount(fs, letter + ":", options, 1));
            var e = Stopwatch.StartNew();

            while (e.ElapsedMilliseconds < 3000)
            {
                Thread.Sleep(200);
                if (t.Exception != null)
                {
                    throw t.Exception;
                }
                if (Directory.Exists(letter + ":\\"))
                {
                    return(fs);
                }
            }
            return(fs);
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: danielga/win-sshfs
        static void Start(Options options)
        {
            var auths = GetAuthMechanisms(options);

            var fs = auths
                     .Select(auth => AttemptConnection(auth.Item1, auth.Item2, options.Path))
                     .FirstOrDefault(result => result != null);

            if (fs == null)
            {
                throw new InvalidOperationException(
                          "Could not connect to server with any known authentication mechanism");
            }

            fs.Disconnected  += (sender, e) => Environment.Exit(0);
            fs.ErrorOccurred += (sender, e) => Environment.Exit(0);

            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
                e.Cancel = true;
                Console.WriteLine("Ctrl-C detected, start exiting . . .");
                Dokan.Unmount(options.DriveLetter);
            };

            ILogger logger = null; // Use default logger in DokanNet

            if (options.Logging)
            {
                logger = new ConsoleLogger(); // Verbose
            }
            else
            {
                logger = new NullLogger(); // Override the default logger in DokanNet
            }
            fs.Mount($"{options.DriveLetter}", logger);
            Console.WriteLine("Program exited gracefully.");
        }
コード例 #20
0
ファイル: Mounter.cs プロジェクト: mthompson2/dokan-dotnet
 public static void AssemblyCleanup()
 {
     mounterThread.Abort();
     Dokan.Unmount(DokanOperationsFixture.MOUNT_POINT[0]);
     Dokan.RemoveMountPoint(DokanOperationsFixture.MOUNT_POINT.ToString(CultureInfo.InvariantCulture));
 }
コード例 #21
0
 public static void Unmount(char letter)
 {
     Dokan.Unmount(letter);
 }
コード例 #22
0
 public static void AssemblyCleanup()
 {
     mounterThread.Abort();
     Dokan.Unmount(DokanOperationsFixture.MOUNT_POINT[0]);
     Dokan.RemoveMountPoint(DokanOperationsFixture.MOUNT_POINT);
 }
コード例 #23
0
ファイル: frmMain.cs プロジェクト: vidarw/RVWorld
 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     Dokan.Unmount(vDriveLetter);
 }
コード例 #24
0
ファイル: frmMain.cs プロジェクト: vidarw/RVWorld
 private void closeVDriveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Dokan.Unmount(vDriveLetter);
 }
コード例 #25
0
        private int Mount(string passPhrase, IList <string> userNames)
        {
            var mountSection = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Sections[MountSection.Name] as MountSection;

            if (mountSection == null)
            {
                throw new ConfigurationErrorsException("Mount configuration missing");
            }

            settingsPassPhrase = passPhrase;

            try {
                using (var logFactory = new LogFactory()) {
                    logger = logFactory.GetCurrentClassLogger();
                    var factory = InitializeCloudDriveFactory(mountSection.LibPath);
                    using (var tokenSource = new CancellationTokenSource()) {
                        var tasks = new List <Task>();
                        foreach (var driveElement in mountSection.Drives.Where(d => !userNames.Any() || userNames.Contains(d.UserName)))
                        {
                            var drive = factory.CreateCloudDrive(driveElement.Schema, driveElement.UserName, driveElement.Root, new CloudDriveParameters()
                            {
                                ApiKey = driveElement.ApiKey, EncryptionKey = driveElement.EncryptionKey, Parameters = driveElement.GetParameters()
                            });
                            if (!drive.TryAuthenticate())
                            {
                                var displayRoot = drive.DisplayRoot;
                                drive.Dispose();
                                logger.Warn($"Authentication failed for drive '{displayRoot}'");
                                continue;
                            }

                            var operations = new CloudOperations(drive, logger);

                            // HACK: handle non-unique parameter set of DokanOperations.Mount() by explicitely specifying AllocationUnitSize and SectorSize
                            tasks.Add(Task.Run(() => operations.Mount(driveElement.Root, DokanOptions.RemovableDrive | DokanOptions.MountManager | DokanOptions.CurrentSession, mountSection.Threads, 1100, TimeSpan.FromSeconds(driveElement.Timeout != 0 ? driveElement.Timeout : 20), null, 512, 512), tokenSource.Token));

                            var driveInfo = new DriveInfo(driveElement.Root);
                            while (!driveInfo.IsReady)
                            {
                                Thread.Sleep(10);
                            }
                            logger.Info($"Drive '{drive.DisplayRoot}' mounted successfully.");
                        }

                        Console.WriteLine("Press CTRL-BACKSPACE to clear log, any other key to unmount drives");
                        while (true)
                        {
                            var keyInfo = Console.ReadKey(true);
                            if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control) && keyInfo.Key == ConsoleKey.Backspace)
                            {
                                Console.Clear();
                            }
                            else
                            {
                                break;
                            }
                        }

                        tokenSource.Cancel();

                        return(0);
                    }
                }
            } catch (Exception ex) {
                Console.Error.WriteLine($"{ex.GetType().Name}: {ex.Message}");
                return(-1);
            } finally {
                foreach (var driveElement in mountSection.Drives.Cast <DriveElement>())
                {
                    Dokan.Unmount(driveElement.Root[0]);
                }
                UIThread.Shutdown();
            }
        }
コード例 #26
0
 public void Unmount()
 {
     _cancellation.Cancel();
     Dokan.Unmount(DriveLetter);
     Mounted = false;
 }
コード例 #27
0
ファイル: App.xaml.cs プロジェクト: AndyZhu1991/ZipFileSystem
 protected override void OnExit(ExitEventArgs e)
 {
     Dokan.Unmount(MOUNT_POINT);
     taskbarIcon?.Dispose(); //the icon would clean up automatically, but this is cleaner
     base.OnExit(e);
 }
コード例 #28
0
 public void Dispose()
 {
     //_mounterThread.Abort();
     Dokan.Unmount(MOUNT_POINT[0]);
     Dokan.RemoveMountPoint(MOUNT_POINT);
 }
コード例 #29
0
 public NtStatusCodes Unmount(DokanFileInfo info)
 {
     return(Dokan.Unmount(DriveLetter) ? NtStatusCodes.VolumeMounted : NtStatusCodes.WrongVolume);
 }
コード例 #30
0
 private void Unmount() => Dokan.Unmount(_settings.Drive);