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

  • 相关阅读:
    实验二 K-近邻算法及应用
    实验1 感知器及其应用
    实验三 面向对象分析与设计
    结构化分析与设计
    实验一 软件开发文档与工具的安装与使用
    ATM管理系统
    流程图与活动图的区别与联系
    四则运算
    实验四 决策树算法及应用
    实验三 朴素贝叶斯算法及应用
  • 原文地址:https://www.cnblogs.com/loushangshaonian/p/2499149.html
Copyright © 2011-2022 走看看