System.IO.DirectoryNotFoundException when path is longer than 260 characters [duplicate]

心不动则不痛 提交于 2019-12-11 06:58:37

问题


I have ASP.NET Core MVC project (targeting .NET 4.62) and I'm trying to save files. Everything works while the length of the path is under 260 (or 248 I'm not sure), but when it's longer I get a System.IO.DirectoryNotFoundException. Previously when I was targeting .NET 4.61 I was getting Path too long exception, I've read that the problem is fixed in .NET 4.62 but not for me.

Here's exception that I'm getting while path is too long

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

I'm pretty sure that directory exists.


回答1:


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



来源:https://stackoverflow.com/questions/48409118/system-io-directorynotfoundexception-when-path-is-longer-than-260-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!