C# – ASP.NET Publish Error (The specified path, file name, or both are too long)

asp.netcpublishwebforms

I am getting an error like the following while publishing a project with Visual Studio:

Copying file Areas\AdminPanel\Content\assets\global\plugins\bootstrap-editable\inputs-ext\wysihtml5\bootstrap-wysihtml5-0.0.2\bootstrap-wysihtml5-0.0.2.css to obj\Release\Package\PackageTmp\Areas\AdminPanel\Content\assets\global\plugins\bootstrap-editable\inputs-ext\wysihtml5\bootstrap-wysihtml5-0.0.2\bootstrap-wysihtml5-0.0.2.css failed. 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.

Is there a simple way to solve this problem or should I make the path shorter?

I am working with ASP.NET Web Forms btw.

Best Answer

That is a Windows limitation. You can disable it this way:

  1. Execute 'regedit.exe'
  2. Navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem"

  3. Find a value named LongPathsEnabled and double-click it. If you don’t see the value listed, you’ll need to create it by right-clicking the FileSystem key, choosing New > DWORD (32-bit) Value, and then naming the new value LongPathsEnabled

  4. Change the value from 0 to 1 in the “Value data” box and then click OK.

After that, you would probably have to restart visual studio.

Related Topic