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!

Topics Coverage:


๐ŸŽ‰ We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram