public static string BrowseFTPDestination(string name, WinInetFTPFileDestination destination, string currentPath, ErrorHandler errorHandler, IWin32Window owner) { PublishFolderPicker folderPicker = new PublishFolderPicker(name, errorHandler); using (folderPicker) { try { using (new WaitCursor()) destination.Connect(); folderPicker.Destination = destination; //default the selected path to what's in the textField (if it exists!) if (!currentPath.Equals("")) { if (!currentPath.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { currentPath = destination.HomeDir + "/" + currentPath; } folderPicker.SelectedPath = currentPath; } else { string currDirectory = destination.HomeDir; if (!currDirectory.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { currDirectory = "/" + currDirectory; } folderPicker.SelectedPath = currDirectory; } if (folderPicker.ShowDialog(owner) == DialogResult.OK) { return(folderPicker.SelectedPath); } } catch (Exception ex) { if (errorHandler != null) { errorHandler(ex); } } finally { try { destination.Disconnect(); } catch (Exception) { //eat it since we've already reported the error and this error //is probably because no valid connection was ever established } } return(null); } }
public static string BrowseFTPDestination(string name, WinInetFTPFileDestination destination, string currentPath, ErrorHandler errorHandler, IWin32Window owner) { PublishFolderPicker folderPicker = new PublishFolderPicker(name, errorHandler); using (folderPicker) { try { using (new WaitCursor()) destination.Connect(); folderPicker.Destination = destination; //default the selected path to what's in the textField (if it exists!) if (!currentPath.Equals("")) { if (!currentPath.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { currentPath = destination.HomeDir + "/" + currentPath; } folderPicker.SelectedPath = currentPath; } else { string currDirectory = destination.HomeDir; if (!currDirectory.StartsWith("/", StringComparison.OrdinalIgnoreCase)) currDirectory = "/" + currDirectory; folderPicker.SelectedPath = currDirectory; } if (folderPicker.ShowDialog(owner) == DialogResult.OK) { return folderPicker.SelectedPath; } } catch (Exception ex) { if (errorHandler != null) errorHandler(ex); } finally { try { destination.Disconnect(); } catch (Exception) { //eat it since we've already reported the error and this error //is probably because no valid connection was ever established } } return null; } }