Reputation: 62886
The error
System.IO.IOException
HResult=0x8007007B
Message=The filename, directory name, or volume label syntax is incorrect. : 'c:\xyz\aida\aida-xyz-mining\Types\SpecFlowTest.Reporting.UI\SpecFlowTest.Reporting.UI.OldSuites.FunctionalTest.Distribution.SystemReport.V2SystemReport.DistributeACopyOfASystemV2ReportWithGroupingAndAccessAuthorizationUncheckedForDistributorDistributeACopyOfASystemV2ReportWithGroupingAndAccessAuthorizationUncheckedForDistributorFeature.json'
Source=System.Private.CoreLib
StackTrace:
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
(The absurdly long file name, if possible, I would prefer to keep - it is a real type name generated by SpecFlow)
The failing line of code is new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, 102400)
My steps to resolve the issue
Read https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry and checked the registry, added app.manifest and even tried with the \\?\
prefix (which is not supposed to be needed) - to no avail:
Registry
C:\> (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled").LongPathsEnabled
1
C:\>
Application manifest
C:\xyz\CSTool\CSTool> grep app.manifest .\CSTool.csproj
<ApplicationManifest>app.manifest</ApplicationManifest>
C:\xyz\CSTool\CSTool> cat .\app.manifest
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
</windowsSettings>
</application>
</assembly>
C:\xyz\CSTool\CSTool>
This has no effect. What am I missing?
EDIT 1
It seems long file paths do work, but the file name itself (including the extension) is limited to 255 characters.
Not sure if there is any way around it without renaming the file. Also it is hard to find any documentation about just the file name length, not the whole file path length.
Upvotes: 0
Views: 57