public void Dispose() { Debug.WriteLine("Dispose"); _threadCancel?.Cancel(); _pauseEvent?.Set(); try { Dokan.RemoveMountPoint($"{Letter}:\\"); if (_filesystem != null) { _filesystem.Dispose(); _filesystem = null; } } catch { if (Status != DriveStatus.Unmounted) { Status = DriveStatus.Unmounted; } } finally { _filesystem = null; } _mountCancel?.Dispose(); _threadCancel?.Dispose(); _pauseEvent?.Dispose(); }
public void Unmount() { if (this.reconnectThread != Thread.CurrentThread) { this.stopReconnect(); } if (_threadCancel != null) { _threadCancel.Cancel(); } if (_pauseEvent != null) { _pauseEvent.Set(); } Debug.WriteLine("Unmount"); Status = DriveStatus.Unmounting; try { Dokan.RemoveMountPoint($"{Letter}:\\"); _filesystem?.Dispose(); } catch { //Status = DriveStatus.Unmounted; // OnStatusChanged(EventArgs.Empty); } finally { _filesystem = null; Status = DriveStatus.Unmounted; OnStatusChanged(EventArgs.Empty); } }
public void Dispose() { Debug.WriteLine("Dispose"); if (_threadCancel != null) _threadCancel.Cancel(); if (_pauseEvent != null) _pauseEvent.Set(); try { Dokan.RemoveMountPoint(String.Format("{0}:\\", Letter)); if (_filesystem != null) { _filesystem.Dispose(); _filesystem = null; } } catch { Status = DriveStatus.Unmounted; } finally { _filesystem = null; } if (_mountCancel != null) {_mountCancel.Dispose();} if (_threadCancel != null) {_threadCancel.Dispose();} if (_pauseEvent != null) {_pauseEvent.Dispose();} }
public void Unmount() { Debug.WriteLine("Unmount"); Status = DriveStatus.Unmounting; try { // Dokan.Unmount(Letter); Dokan.RemoveMountPoint(String.Format("{0}:\\", Letter)); if (_filesystem != null) { _filesystem.Dispose(); } } catch { //Status = DriveStatus.Unmounted; // OnStatusChanged(EventArgs.Empty); } finally { _filesystem = null; } }
private void SetupFilesystem() { Debug.WriteLine("SetupFilesystem"); var info = ConnectionType == ConnectionType.Password ? (ConnectionInfo) new PasswordConnectionInfo(Host, Port, Username, Password) : new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase)); _connection = String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username); _filesystem = new SftpFilesystem(info, Root, _connection); Debug.WriteLine("Connecting..."); _filesystem.Connect(); }
private void SetupFilesystem() { Debug.WriteLine("SetupFilesystem"); var info = ConnectionType == ConnectionType.Password ? (ConnectionInfo) new PasswordConnectionInfo(Host, Port, Username, Password) : new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase)); _connection = Settings.Default.UseNetworkDrive ? String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username) : Name; _filesystem = new SftpFilesystem(info, Root,_connection,Settings.Default.UseOfflineAttribute,false, (int) Settings.Default.AttributeCacheTimeout, (int) Settings.Default.DirContentCacheTimeout); Debug.WriteLine("Connecting..."); _filesystem.Connect(); }
private void SetupFilesystem() { Debug.WriteLine("SetupFilesystem"); var info = ConnectionType == ConnectionType.Password ? (ConnectionInfo) new PasswordConnectionInfo(Host, Port, Username, Password) : new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase)); _connection = String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username); _filesystem = new SftpFilesystem(info, Root,_connection); Debug.WriteLine("Connecting..."); _filesystem.Connect(); }
public void Unmount() { Debug.WriteLine("Unmount"); Status = DriveStatus.Unmounting; try { // Dokan.Unmount(Letter); Dokan.RemoveMountPoint(String.Format("{0}:\\", Letter)); if (_filesystem != null) { _filesystem.Dispose(); } } catch { Status = DriveStatus.Unmounted; OnStatusChanged(EventArgs.Empty); } finally { _filesystem = null; } }
private void SetupFilesystem() { Debug.WriteLine("SetupFilesystem {0},{1},{2},{3}", Host, Port, Username, ConnectionType.ToString()); ProxyTypes pt = ProxyTypes.None; switch (ProxyType) { case 1: pt = ProxyTypes.Http; break; case 2: pt = ProxyTypes.Socks4; break; case 3: pt = ProxyTypes.Socks5; break; } int ProxyPort = 8080; var Proxy = ProxyHost; if (ProxyHost != null) { var s = ProxyHost.Split(':'); if (s.Length > 1) { Int32.TryParse(s[1], out ProxyPort); Proxy = s[0]; } } ConnectionInfo info; switch (ConnectionType) { case ConnectionType.Pageant: var agent = new PageantProtocol(); if (pt == ProxyTypes.None) { info = new AgentConnectionInfo(Host, Port, Username, agent); } else if (ProxyUser.Length > 0) { info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, agent); } else { info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, agent); } break; case ConnectionType.PrivateKey: if (pt == ProxyTypes.None) { info = new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase)); } else if (ProxyUser.Length > 0) { info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, new PrivateKeyFile(PrivateKey, Passphrase)); } else { info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, new PrivateKeyFile(PrivateKey, Passphrase)); } break; default: if (pt == ProxyTypes.None) { info = new PasswordConnectionInfo(Host, Port, Username, Password); } else if (ProxyUser.Length > 0) { info = new PasswordConnectionInfo(Host, Username, Password, pt, Proxy, ProxyPort, ProxyUser, ProxyPass); } else { info = new PasswordConnectionInfo(Host, Port, Username, Password, pt, Proxy, ProxyPort); } break; } _connection = Settings.Default.UseNetworkDrive ? String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username) : Name; _filesystem = new SftpFilesystem(info, Root, _connection, Settings.Default.UseOfflineAttribute, false, (int)Settings.Default.AttributeCacheTimeout, (int)Settings.Default.DirContentCacheTimeout); Debug.WriteLine("Connecting..."); _filesystem.KeepAliveInterval = new TimeSpan(0, 0, 60); _filesystem.Connect(); }
private void SetupFilesystem() { Debug.WriteLine("SetupFilesystem {0},{1},{2},{3}",Host,Port,Username,ConnectionType.ToString()); ProxyTypes pt = ProxyTypes.None; switch (ProxyType) { case 1: pt = ProxyTypes.Http; break; case 2: pt = ProxyTypes.Socks4; break; case 3: pt = ProxyTypes.Socks5; break; } int ProxyPort = 8080; var Proxy = ProxyHost; if (ProxyHost != null) { var s = ProxyHost.Split(':'); if (s.Length > 1) { Int32.TryParse(s[1], out ProxyPort); Proxy = s[0]; } } ConnectionInfo info; switch (ConnectionType) { case ConnectionType.Pageant: var agent = new PageantProtocol(); if (pt == ProxyTypes.None) { info = new AgentConnectionInfo(Host, Port, Username, agent); } else if (ProxyUser.Length>0) { info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, agent); } else { info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, agent); } break; case ConnectionType.PrivateKey: if (pt == ProxyTypes.None) { info = new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase)); } else if (ProxyUser.Length > 0) { info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, new PrivateKeyFile(PrivateKey, Passphrase)); } else { info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, new PrivateKeyFile(PrivateKey, Passphrase)); } break; default: if (pt == ProxyTypes.None) { info = new PasswordConnectionInfo(Host, Port, Username, Password); } else if (ProxyUser.Length > 0) { info = new PasswordConnectionInfo(Host, Username, Password, pt, Proxy, ProxyPort, ProxyUser, ProxyPass); } else { info = new PasswordConnectionInfo(Host, Port, Username, Password, pt, Proxy, ProxyPort); } break; } _connection = Settings.Default.UseNetworkDrive ? String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username) : Name; _filesystem = new SftpFilesystem(info, Root,_connection,Settings.Default.UseOfflineAttribute,false, (int) Settings.Default.AttributeCacheTimeout, (int) Settings.Default.DirContentCacheTimeout); Debug.WriteLine("Connecting..."); _filesystem.KeepAliveInterval = new TimeSpan(0, 0, 60); _filesystem.Connect(); }