C# 文件迁移
/// <summary>
/// 图片文件迁移
/// </summary>
private void MoveFile(string Frompath, string directoryPath)
{
string[] picList = Directory.GetFiles(Frompath, "*.jpg"); //图片
string[] txtList = Directory.GetFiles(Frompath, "*.txt"); //文本文件
string[] pdfList = Directory.GetFiles(Frompath, "*.pdf"); //PDF文件
foreach (string f in picList)
{
//取得文件名.
string fName = f.Substring(Frompath.Length + 1);
File.Copy(Path.Combine(Frompath, fName), Path.Combine(directoryPath, fName), true);
}
foreach (string f in txtList)
{
string fName = f.Substring(Frompath.Length + 1);
try
{
File.Copy(Path.Combine(Frompath, fName), Path.Combine(directoryPath, fName));
}
// 捕捉异常.
catch (IOException copyError)
{
MessageBox.Show(copyError.Message);
}
}
foreach (string f in pdfList)
{
string fName = f.Substring(Frompath.Length + 1);
try
{
File.Copy(System.IO.Path.Combine(Frompath, fName), System.IO.Path.Combine(directoryPath, fName));
}
catch (IOException copyError)
{
MessageBox.Show(copyError.Message);
return;
}
}
//删除原始文件夹里的文件
foreach (string f in txtList)
{
File.Delete(f);
}
foreach (string f in picList)
{
File.Delete(f);
}
foreach (string f in pdfList)
{
File.Delete(f);
}
}
- AutoCAD.Net/C#.Net QQ群:193522571 多个框架共一套代码在进行迁移时的问题,properties,resource,未能加载文件或程序集“System.Drawing, Version=4.0.0.0
- C# TCP实现多个客户端与服务端 数据 与 文件的传输
- 一个C#多线程读文件列表的方法
- C#文件的一些操作,值得看看!
- c# 创建文件
- 在C#使用文件监控对象FileSystemWatcher的几种方案
- mysql数据文件迁移到新的硬盘分区的方法
- C# 判断文件夹和文件是否存在的方法
- C#计算文件MD5校验的方法
- C#获取文件夹及文件的大小与占用空间的方法
- asp.net(c#)使用HttpWebRequest附加携带请求参数以post方式模拟上传大文件(以图片为例)到Web服务器端
- C# 根据配置文件实例化类
- C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件
- C#利用SharpZipLib进行文件的压缩和解压缩
- c#选择文件保存路径
- C# 打包文件,制作EXE安装文件
- c# 获取应用程序exe文件路径及退出应用程序的几种方法
- Atitit 文件上传 架构设计 实现机制 解决方案 实践java php c#.net js javascript c++ python
- [No0000DC]C# FileHelper 本地文件、文件夹操作类封装FileHelper
- C#常用文件相关操作