路径长度超过260个字符时System.IO.DirectoryNotFoundException

时间:2018-01-23 19:11:00

标签: c# asp.net asp.net-core .net-framework-version

我有ASP.NET Core MVC项目(针对.NET 4.62),我正在尝试保存文件。一切都有效,而路径的长度低于260(或248我不确定),但是当它长了一段时间后,我得到System.IO.DirectoryNotFoundException。以前当我的目标是.NET 4.61时,我得到了路径太长的异常,我已经读过这个问题在.NET 4.62中得到修复但不适用于我。

我在路径太长时获得了例外

img1

File.Copy(file, Path.Combine(path, dbFile.Id.ToString()));

我很确定该目录存在。

1 个答案:

答案 0 :(得分:2)

I refer you to this answer on why the ~255 limit filename|folder. Probabaly a probleme because you are on Windows on NTFS. Nothing to do with .NET framework