管理

C#删除文件夹和文件到回收站示例

Posted on 2022-11-09 19:00  lzhdim  阅读(155)  评论(0编辑  收藏  举报
using System;
using Microsoft.VisualBasic.FileIO;
namespace leaver {   class Program   {     static void Main(string[] args)     {       Console.WriteLine("删除文件到回收站");       string filepath = "leaver.txt";       FileSystem.DeleteFile(filepath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);       Console.WriteLine("删除文件完成");//keleyi.com       Console.WriteLine("删除文件夹到回收站");       string dirpath = "leaver";       FileSystem.DeleteDirectory(dirpath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);       Console.WriteLine("删除文件夹完成");     }   } }

 

Copyright © 2000-2022 Lzhdim Technology Software All Rights Reserved