繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Windows开发 >> 用Visual C#来清空回收站(2)

用Visual C#来清空回收站(2)

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:23  文字大小:【】【】【
简介:四.程序的源代码(recycled.cs)、编译方法及运行后的界面:   (1).程序的源代码:recycled.cs: using System.IO ; using System.Windows.Forms ; //导入程序中用到的名称空间 class Recycle { public st...
关键字:C# 回收站 Visual

四.程序的源代码(recycled.cs)、编译方法及运行后的界面:

  (1).程序的源代码:recycled.cs:

using System.IO ;

using System.Windows.Forms ; //导入程序中用到的名称空间

class Recycle

{

public static void Main ( )

{

int c = 0 ; // 定义此变量主要是来判断目录中是否有文件

foreach ( string s1 in Directory.GetFiles ( "c:\\recycled" ) ) // 返回文件名称字符串行时的枚举类型

{

++c ;

}

if ( c > 0 ) //判断是否存在文件如果 c > 0则回收站有文件,反之则没有

{

 DialogResult r = MessageBox.Show ( "是否确定?" , "垃圾处理!" ,

         MessageBoxButtons.YesNo , MessageBoxIcon.Question ) ;

 // 显示"确定"和"取消"二个按钮,图标显示是一个问号。

 int ss=(int)r ;

 if ( ss==6 ) // 按动确定按钮

  { foreach ( string s in Directory.GetFiles ( "c:\\recycled" ) )

   // 把全路径名称房子 s中

   {

    File.Delete ( s ) ; //删除此文件

   }

  }

 }

}

}

责任编辑:admin
相关文章