private List <string> FetchList() { List <string> result = new List <string>(); try { string[] splode, str = mFTP.ListDirectory(FTPHelpers.CombineURL(mAcc.FTPAddress, mAcc.GetSubFolderPath())); string goodFile; bwRemoteViewer.ReportProgress((int)RemoteViewerTask.ProgressType.UPDATE_PROGRESS_MAX, str.Length); for (int x = 0; x < str.Length; x++) { splode = str[x].Split(' '); goodFile = splode[splode.Length - 1]; if (goodFile.Length > 2 && goodFile.Contains(".")) { result.Add(goodFile); bwRemoteViewer.ReportProgress((int)RemoteViewerTask.ProgressType.ADD_FILE_TO_LISTBOX, goodFile); } } } catch (Exception e) { MessageBox.Show(e.Message, "ZScreen FTP"); } return(result); }
private void sBwViewFile(string file) { string localfile = FileSystem.GetTempFilePath(file); if (!File.Exists(localfile)) { bwRemoteViewer.ReportProgress((int)RemoteViewerTask.ProgressType.FETCHING_FILE, file); try { //mFTP.ChangeDir(mAcc.Path); string directory = Path.GetDirectoryName(localfile); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } mFTP.DownloadFile(FTPHelpers.CombineURL(mAcc.FTPAddress, mAcc.GetSubFolderPath(), file), localfile); } catch (System.Exception ex) { DebugHelper.WriteException(ex, "Error while viewing file in View Remote"); // bwRemoteViewer.ReportProgress((int)RemoteViewerTask.ProgressType.VIEWING_FILE, ""); } } // toDelete.Add(localfile); bwRemoteViewer.ReportProgress((int)RemoteViewerTask.ProgressType.VIEWING_FILE, localfile); }
private void btnDelete_Click(object sender, System.EventArgs e) { try { List <string> list = new List <string>(); foreach (string item in lbFiles.SelectedItems) { list.Add(item); } foreach (string obj in list) { if (!string.IsNullOrEmpty(obj)) { mFTP.DeleteFile(FTPHelpers.CombineURL(mAcc.FTPAddress, mAcc.GetSubFolderPath(), obj)); lbFiles.Items.Remove(obj); } } } catch (Exception ex) { DebugHelper.WriteException(ex, "Error while deleting file in View Remote"); MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } if (lbFiles.Items.Count > 0) { lbFiles.SelectedIndex = 0; } }
private string GetRemotePath(string fileName) { fileName = ZAppHelper.ReplaceIllegalChars(fileName, '_'); while (fileName.IndexOf("__") != -1) { fileName = fileName.Replace("__", "_"); } return(FTPHelpers.CombineURL(FTPAccount.GetSubFolderPath(), fileName)); }
private void lvFTPList_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) { if (lvFTPList.SelectedItems.Count > 0 && !e.Cancel && !string.IsNullOrEmpty(e.DisplayText)) { FtpItem file = (FtpItem)lvFTPList.SelectedItems[0].Tag; if (file.Name != e.DisplayText) { FTPAdapter.Rename(file.FullPath, FTPHelpers.CombineURL(currentDirectory, e.DisplayText)); RefreshDirectory(); } } }
private void FTPCreateDirectory() { InputBox ib = new InputBox { Text = "Create directory", Question = "Please enter the name of the directory which should be created:" }; ib.ShowDialog(); this.BringToFront(); if (ib.DialogResult == DialogResult.OK) { FTPAdapter.MakeDirectory(FTPHelpers.CombineURL(currentDirectory, ib.InputText)); RefreshDirectory(); } }
private void copyURLsToClipboardToolStripMenuItem_Click(object sender, EventArgs e) { string path; List <string> list = new List <string>(); foreach (ListViewItem lvi in lvFTPList.SelectedItems) { FtpItem file = lvi.Tag as FtpItem; if (file != null && file.ItemType == FtpItemType.File) { path = FTPHelpers.CombineURL(Account.GetHttpHomePath(), file.FullPath); list.Add(path); } } string clipboard = string.Join("\r\n", list.ToArray()); if (!string.IsNullOrEmpty(clipboard)) { Clipboard.SetText(clipboard); // ok } }
private void btnSave_Click(object sender, System.EventArgs e) { string dir; folderBrowseDialog.SelectedPath = Engine.ImagesDir; folderBrowseDialog.ShowNewFolderButton = true; if (folderBrowseDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dir = folderBrowseDialog.SelectedPath)) { try { foreach (string str in lbFiles.SelectedItems) { mFTP.DownloadFile(FTPHelpers.CombineURL(mAcc.FTPAddress, mAcc.GetSubFolderPath(), str), Path.Combine(dir, Path.GetFileName(str))); } } catch { MessageBox.Show("Save Failed"); } } }
private void lvFTPList_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(string[]))) { Point point = lvFTPList.PointToClient(new Point(e.X, e.Y)); ListViewItem lvi = lvFTPList.GetItemAt(point.X, point.Y); if (lvi != null && e.AllowedEffect == DragDropEffects.Move) { if (tempSelected != null && tempSelected != lvi) { tempSelected.Selected = false; } FtpItem file = lvi.Tag as FtpItem; if (file != null && file.ItemType == FtpItemType.Directory) { string[] filenames = e.Data.GetData(typeof(string[])) as string[]; if (filenames != null) { int renameCount = 0; foreach (string filename in filenames) { if (file.Name != filename) { string path = FTPHelpers.CombineURL(currentDirectory, filename); string movePath = string.Empty; if (file.ItemType == FtpItemType.Unknown) { if (file.Name == ".") { movePath = FTPHelpers.AddSlash(filename, FTPHelpers.SlashType.Prefix, 2); } else if (file.Name == "..") { movePath = FTPHelpers.AddSlash(filename, FTPHelpers.SlashType.Prefix); } } else { movePath = FTPHelpers.CombineURL(file.FullPath, filename); } if (!string.IsNullOrEmpty(movePath)) { FTPAdapter.Rename(path, movePath); renameCount++; } } } if (renameCount > 0) { RefreshDirectory(); } } } } tempSelected = null; } else if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; if (files != null) { FTPAdapter.UploadFiles(files, currentDirectory); RefreshDirectory(); } } }