如何在c sharp中复制,粘贴,删除文件 [英] How to copy, paste, delete files in c sharp

查看:208
本文介绍了如何在c sharp中复制,粘贴,删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何通过GUI(表格)复制,粘贴和删除c sharp中的文件,我需要一个示例或指导。我正在构建Windows资源管理器。提前非常感谢。

I need to know how to copy, paste, delete files in c sharp via the GUI (form), I need an example or guidance to do so. It is for Windows Explorer that I''m building. In advance thank you very much.

推荐答案

using System.IO;

string file = "C:\\Program Files\\Cortex\\Log\\Backup.log";
string filecp = "C:\\Program Files\\Cortex\\Log\\Backup_copy.log";

void Delete()
{
   if (!File.Exists(file))
      File.Delete(file);
}

void Copy()
{
   if (!File.Exists(file))
      File.Copy(file, filecp);
}


简短答案应该足够了: http://msdn.microsoft.com/en-us/library/system.io.file.aspx [ ^ ]



更重要的是, Microsoft Q209354



-SA
The short answer should be enough: http://msdn.microsoft.com/en-us/library/system.io.file.aspx[^].

More importantly, Microsoft Q209354.

—SA


这篇关于如何在c sharp中复制,粘贴,删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆