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!













Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap