Delete() public method

删除文件或文件夹
public Delete ( string path, bool recursive ) : bool
path string
recursive bool 是否删除子文件夹
return bool
Esempio n. 1
0
 //删除选中
 private void btDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定删除选中的文件或文件夹?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
         == System.Windows.Forms.DialogResult.Yes)
     {
         if (lvFiles.SelectedItems.Count > 0)
         {
             foreach (ListViewItem item in lvFiles.SelectedItems)
             {
                 FileStatus myfile = item.Tag as FileStatus;
                 if (myfile != null)
                 {
                     FSClient client = new FSClient();
                     bool     result = client.Delete(myfile.Path, true);
                     string   msg    = string.Format("{2}:{0} 删除{1}", Path.GetFileName(myfile.Path), result ? "成功" : "失败", myfile.Isdir ? "文件夹" : "文件");
                     lbProgressTxt.Text = msg;
                 }
                 Application.DoEvents();
             }
             //重新加载
             LoadFileStatus(CurrentPath);
         }
     }
 }
Esempio n. 2
0
 //删除选中
 private void btDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定删除选中的文件或文件夹?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
         == System.Windows.Forms.DialogResult.Yes)
     {
         if (lvFiles.SelectedItems.Count > 0)
         {
             foreach (ListViewItem item in lvFiles.SelectedItems)
             {
                 FileStatus myfile = item.Tag as FileStatus;
                 if (myfile != null)
                 {
                     FSClient client = new FSClient();
                     bool result = client.Delete(myfile.Path, true);
                     string msg = string.Format("{2}:{0} 删除{1}", Path.GetFileName(myfile.Path), result ? "成功" : "失败", myfile.Isdir ? "文件夹" : "文件");
                     lbProgressTxt.Text = msg;
                 }
                 Application.DoEvents();
             }
             //重新加载
             LoadFileStatus(CurrentPath);
         }
     }
 }