且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何删除目录文件夹中的文件

更新时间:2022-03-12 01:20:40

你在datagridview上工作所以你需要一些gridview行删除概念你使用列名如项目模板



只需按照rowdelete事件自动删除目录文件夹中的网格视图



you work on datagridview so you need some gridview row delete concept your using column names like item template

just follow the rowdelete event and automatically delete the grid view in directory folder

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
     dt.Rows.RemoveAt(e.RowIndex); 
    GridView1.DataSource = dt;
    GridView1.DataBind();
}


读一读这个



system.io.file.delete [ ^ ]



您还必须确保您的应用程序或网站用户可以访问您要从中删除文件的文件夹。
Have a read of this

system.io.file.delete[^]

you will also have to make sure that your application or the website user has access to the folder that you want to delete the file from.


如果您正在使用datagridview,则选中复选框值为true或false的复选项的复选框

提供下面的一些代码可以帮助您批次



If you are using datagridview then put checkbox for select items where checkbox value on true or false
Providing some code below which will help you lot

foreach (DataGridViewRow item in dgList.Rows)
{
if (((DataGridViewCheckBoxCell)item.Cells["chkBodyup"]).Value != null)
   if (((DataGridViewCheckBoxCell)item.Cells["chkBodyup"]).Value.ToString().ToUpper() == "TRUE")
       {
       string filepth = item.Cells[6].Value.ToString();
       FileInfo fl = new FileInfo(path);
       fl.Delete();
      }

  }