private IDokanOperations GetSubSystemOperations(SftpDrive drive) { if (drive == null) { return(null); } if ((drive.Status != DriveStatus.Mounted) && (drive.Status != DriveStatus.Mounting)) { try { LogFSActionInit("MOUNT", "", drive, "Mounting..."); drive.Mount(); } catch (Exception e) { if (e.Message == "Pageant not running") { return(null); } LogFSActionError("MOUNT", "", drive, "Mounting failed: {0}", e.Message); //Log("VFS: Mount error: {0}", e.Message); //maybe failed because of letter blocked, but we dont need the letter: if (drive.Letter != ' ') { LogFSActionError("MOUNT", "", drive, "Trying without mounting drive {0}", drive.Letter); char l = drive.Letter; drive.Letter = ' '; try { drive.Mount(); drive.Letter = l; } catch { LogFSActionError("MOUNT", "", drive, "Mounting failed again: {0}", e.Message); //connection error drive.Letter = l; //Log("VFS: Mount error: {0}", e.Message); return(null); } } else { return(null); } } } return((IDokanOperations)drive._filesystem); }
public static void Run(string[] args) { var drive = new SftpDrive { Name = args[0], Port = Convert.ToInt32(args[1]), MountPoint = $"/sftpg/{args[2]}/data/", Host = args[3], Letter = Utilities.GetAvailableDrives().Last(), Root = "/data", KeepAliveInterval = 30, ConnectionType = ConnectionType.Password, Username = args[4], Password = args[5] }; do { try { drive.Mount(); } catch (Exception) { } Thread.Sleep(TimeSpan.FromSeconds(15)); } while(drive.Status != DriveStatus.Mounted); while (true) { Thread.Sleep(TimeSpan.FromMinutes(30)); while (drive.Status != DriveStatus.Mounted) { drive.Mount(); } } }
private void MountDrive(SftpDrive drive) { Task.Factory.StartNew(() => { try { drive.Mount(); } catch (Exception e) { LogHelper.WriteError("Mount Error", e); BeginInvoke(new MethodInvoker(() => { if ( (drive.Tag as ListViewItem) .Selected) { muButton.Enabled = true; } })); if (Visible) { BeginInvoke( new MethodInvoker( () => MessageBox.Show(this, String.Format("{0} could not connect:\n{1}", drive.Name, e.Message), Text))); } else { ShowBallon(String.Format("{0} : {1}", drive.Name, e.Message), true); } } }); }
private void MountDrive(SftpDrive drive) { Task.Factory.StartNew(() => { try { drive.Mount(); } catch (Exception e) { BeginInvoke(new MethodInvoker(() => { if ( (drive.Tag as ListViewItem) .Selected) { muButton.Enabled = true; } })); if (Visible) { BeginInvoke( new MethodInvoker( () => MessageBox.Show(this, String.Format("{0} could not connect:\n{1}", drive.Name, e.Message), Text))); } else { ShowBallon(String.Format("{0} : {1}", drive.Name, e.Message),true); } } }); }
private IDokanOperations GetSubSystemOperations(SftpDrive drive) { if (drive == null) return null; if ((drive.Status != DriveStatus.Mounted)&&(drive.Status != DriveStatus.Mounting)) { try { LogFSActionInit("MOUNT", "", drive, "Mounting..."); drive.Mount(); } catch (Exception e) { if (e.Message == "Pageant not running") { return null; } LogFSActionError("MOUNT", "", drive, "Mounting failed: {0}",e.Message); //Log("VFS: Mount error: {0}", e.Message); //maybe failed because of letter blocked, but we dont need the letter: if (drive.Letter != ' ') { LogFSActionError("MOUNT", "", drive, "Trying without mounting drive {0}", drive.Letter); char l = drive.Letter; drive.Letter = ' '; try { drive.Mount(); drive.Letter = l; } catch { LogFSActionError("MOUNT", "", drive, "Mounting failed again: {0}", e.Message); //connection error drive.Letter = l; //Log("VFS: Mount error: {0}", e.Message); return null; } } else { return null; } } } return ((IDokanOperations)drive._filesystem); }