产出文件可通过file类的delete方法来实现

格式为:deletestring path);

实例:用户输入文件名称,删除对应文件。

 string path = @"C:\Users\Administrator\Desktop\";
                Console.WriteLine("请输入你要删除的文件名(后缀名也要写上)");
                string input = Console.ReadLine();

                string due = path + input;
                if (File.Exists(due))
                {
                    File.Delete(due);
                    Console.WriteLine("删除文件" + input + "成功!");

                }
                else
                {
                    Console.WriteLine("删除的文件不存在!");
                }

            }

 

相关文章:

  • 2021-11-20
  • 2021-06-14
  • 2022-02-15
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-01-25
猜你喜欢
  • 2021-09-02
  • 2021-11-20
  • 2022-12-23
  • 2021-12-12
  • 2021-07-17
  • 2022-12-23
相关资源
相似解决方案