duplicati/duplicati · error · Win32Exception
Failed to retrieve alternate data stream size.
Error message
Failed to retrieve alternate data stream size.
What it means
Thrown by SystemIOWindows.FileLength after a valid handle to an alternate data stream was opened but Win32API.GetFileSizeEx returned false. This is rarer than [420]: the stream was found and opened, yet the kernel could not report its size. The native error code in the Win32Exception explains why.
Source
Thrown at Duplicati/Library/Common/IO/SystemIOWindows.cs:719
{
if (!IsAlternateDataStream(path))
return new FileInfo(AddExtendedDevicePathPrefix(path)).Length;
using SafeFileHandle handle = Win32API.CreateFileW(
AddExtendedDevicePathPrefix(path),
Win32API.FILE_READ_ATTRIBUTES,
Win32API.FILE_SHARE_READ | Win32API.FILE_SHARE_WRITE | Win32API.FILE_SHARE_DELETE, // Broad sharing flags avoid collisions
IntPtr.Zero,
Win32API.OPEN_EXISTING,
0,
IntPtr.Zero);
if (handle.IsInvalid)
throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to open handle to alternative data stream ");
// Retrieve the size directly from the stream handle
if (!Win32API.GetFileSizeEx(handle, out long streamSize))
throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to retrieve alternate data stream size.");
return streamSize;
}
public void CreateSymlink(string symlinkfile, string target, bool asDir)
{
if (FileExists(symlinkfile) || DirectoryExists(symlinkfile))
throw new IOException(string.Format("File already exists: {0}", symlinkfile));
if (asDir)
{
Directory.CreateSymbolicLink(AddExtendedDevicePathPrefix(symlinkfile), target);
}
else
{
File.CreateSymbolicLink(AddExtendedDevicePathPrefix(symlinkfile), target);
}View on GitHub (pinned to 3f348be3e3)
Solutions
- Inspect Win32Exception.NativeErrorCode to determine the kernel-level cause.
- Retry once for transient network errors (e.g. ERROR_NETNAME_DELETED).
- Fall back to reading the stream to compute length if size cannot be queried.
- Skip the stream and log a warning if it is a non-critical metadata stream.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try { len = systemIO.FileLength(adsPath); }
catch (System.ComponentModel.Win32Exception ex)
{
logger.LogError(ex, "GetFileSizeEx failed for {Path} (code {Code})", adsPath, ex.NativeErrorCode);
// fall back to reading the stream to compute length, or skip
} Prevention
- For network-hosted ADS, prefer local staging so size queries are reliable.
- Log NativeErrorCode to distinguish transient network faults from permanent failures.
- Fall back to streaming the stream content to compute size when the kernel cannot report it.
When it happens
Trigger: CreateFileW succeeded but GetFileSizeEx failed on the resulting handle, which can happen when the handle is to a device-backed reparse point, a remote stream whose size is not reported by the redirector, or the stream was truncated mid-call.
Common situations: ADS on files hosted on SMB/Samba shares with protocol limitations; ADS on files backed by special devices; transient I/O during concurrent writers.
Related errors
- Failed to open handle to alternative data stream
- Win32Exception (dynamic OS error message from Marshal.GetLas
- No drive letters available
- File already exists: {0}
- Unable to open the file "{0}" in mode {1}, error: {2} ({3})
AI-assisted analysis of duplicati/duplicati@3f348be3e3 (2026-08-13).
Data as JSON: /api/errors/9bb15029621ceb33.
Report an issue: GitHub.