• 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); 随后也可用其进行检查,看是否已经删除,不过,两者有什么样的区别暂时还不清楚!

  • 相关阅读:
    关于xmlhttprequest的readystate属性的五个状态(转载)
    MySQL在windows下 1045 access denied for user 'root'@'localhost' using password yes 解决办法 (转)
    栈 堆
    代码安全问题
    TSQL 编程规范(摘自网络)
    UCenter 来自网络
    如何调试 asp 程序 摘自: http://hi.baidu.com/artmis_/blog/item/dd859df57c317b7edcc474f0.html
    《大话设计模式》6个原则 转帖
    SliverLight的bug OR Vs2008的bug?
    ifconfig
  • 原文地址:https://www.cnblogs.com/loushangshaonian/p/2499149.html
Copyright © 2020-2023  润新知