Common/IOHelper.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
namespace OPMS.Common
{
public class IOHelper
{
public static void CopyFile(string fileFullPath, string destination, bool isDeleteSourceFile = false, string fileName = "")
{
if (string.IsNullOrWhiteSpace(fileFullPath))
{
throw new ArgumentNullException("fileFullPath", "源文件全路径不能为空");
}
if (!File.Exists(fileFullPath))
{
throw new FileNotFoundException("找不到源文件", fileFullPath);
}
if (!Directory.Exists(destination))
{
throw new DirectoryNotFoundException("找不到目标目录 " + destination);
}
try
{
fileName = string.IsNullOrWhiteSpace(fileName) ? Path.GetFileName(fileFullPath) : fileName;
File.Copy(fileFullPath, Path.Combine(destination, fileName), true);
if (isDeleteSourceFile)
{
File.Delete(fileFullPath);
}
}
catch (Exception)
{
throw;
}
}
public static long GetDirectoryLength(string dirPath)
{
if (!Directory.Exists(dirPath))
{
return 0L;
}
long num = 0L;
DirectoryInfo info = new DirectoryInfo(dirPath);
foreach (FileInfo info2 in info.GetFiles())
{
num += info2.Length;
}
DirectoryInfo[] directories = info.GetDirectories();
if (directories.Length > 0)
{
for (int i = 0; i < directories.Length; i++)
{
num += GetDirectoryLength(directories[i].FullName);
}
}
return num;
后面还有 104 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
