zoukankan      html  css  js  c++  java
  • wen 删除单个指定的文件 asp.net

    using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO;

    namespace FLX.ComplexQuery {     /**//// <summary>     /// deletepic 的摘要说明。     /// </summary>     public class deletepic : System.Web.UI.Page     {         protected System.Web.UI.WebControls.Button Button1;                     private void Page_Load(object sender, System.EventArgs e)         {             // 在此处放置用户代码以初始化页面            }

            private void deletefile(System.IO.DirectoryInfo path)           {               foreach(System.IO.DirectoryInfo d in path.GetDirectories())               {                   deletefile(d);               }               foreach(System.IO.FileInfo f in path.GetFiles())               {                   f.Delete();                 }           } 

            Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码         override protected void OnInit(EventArgs e)         {             //             // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。             //             InitializeComponent();             base.OnInit(e);         }                 /**//// <summary>         /// 设计器支持所需的方法 - 不要使用代码编辑器修改         /// 此方法的内容。         /// </summary>         private void InitializeComponent()         {                this.Button1.Click += new System.EventHandler(this.Button1_Click);             this.Load += new System.EventHandler(this.Page_Load);

            }         #endregion

            private void Button1_Click(object sender, System.EventArgs e)         {                        System.IO.DirectoryInfo path = new System.IO.DirectoryInfo(Server.MapPath("~/ChartImages"));             deletefile(path);         }     } }

    对于删除文件,可以使用File.delete(path); 随后也可用其进行检查,看是否已经删除,不过,两者有什么样的区别暂时还不清楚!

  • 相关阅读:
    [转载]WSUS客户端排错--使用wsus client tools
    [转载]vSphere ESXi主机配置iSCSI存储
    RHEL6.5下oracle11G的监听启动停止
    配置EM遇到的问题:*_orcl not foundlistener not upError creating the repository
    chrome有道翻译--书签栏关闭开启快捷键
    linux下sqlplus实现浏览历史命令和删除错误字母功能
    windows下plsql安装并配置oracle client
    chrome google浏览器添加AdBlock插件
    Python基础之异常处理
    Python基础之finally异常处理
  • 原文地址:https://www.cnblogs.com/loushangshaonian/p/2499149.html
Copyright © 2011-2022 走看看