Resolve System.IO.PathTooLongException [Sharepoint C# .Net]


System.IO.PathTooLongException: 
The specified path, file name, or both are too long. 
The fully qualified file name must be less than 260 characters, 
and the directory name must be less than 248 characters.
Solution:

If you are using Windows 10 this issue of "Maximum Path Length Limitation" can be resolved by setting LongPathsEnabled value to 1 by the below powershell command.

Powershell:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

⛏️Reference:

- https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN

- https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell

System.IO.PathTooLongException
System.IO.PathTooLongException
Hashtags:

#Sharepoint #cSharp #dotNet


Have Questions? Post them here!



Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.