小编Lev*_*ath的帖子

File.Copy错误:由于文件系统限制,无法完成请求的操作

在结构中获得超过4000000个jpeg文件后,我们添加了新的问题.File.Copy抛出异常:由于文件系统限制,无法完成请求的操作.

有解决方案吗

信息

    public bool AddFile(Uri uri, string path, bool withDelete = false)
    {
        var sourceFilePath = path;
        var destinationFilePath = Path.GetFullPath(uri.LocalPath);

        try
        {
            if (!File.Exists(sourceFilePath))
            {
                sourceFilePath = Directory.EnumerateFiles(sourceFilePath).FirstOrDefault();
                destinationFilePath = Path.Combine(destinationFilePath, Path.GetFileName(sourceFilePath));
            }

            if (!Directory.Exists(Path.GetDirectoryName(destinationFilePath)))
                Directory.CreateDirectory(Path.GetDirectoryName(destinationFilePath));

            if (withDelete && File.Exists(destinationFilePath))
                File.Delete(destinationFilePath);

            File.Copy(sourceFilePath, destinationFilePath);

            return true;
        }
        catch (Exception exc)
        {
            ServiceCore.GetLogger().Error(exc);
            throw exc;
        }
    }
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

    2013-03-28 14:10:48.3784[Info]: 47356388:Unive.NetService.SimpleServices.DocumentManagementSerivce..ctor: Entry
    2013-03-28 14:10:48.4740[Info]: Static:Unive.NetService.SimpleServices.DocumentManagementSerivce..ctor: …
Run Code Online (Sandbox Code Playgroud)

.net c# exception

6
推荐指数
1
解决办法
4841
查看次数

标签 统计

.net ×1

c# ×1

exception ×1