stride3d/stride · error · InvalidOperationException
Unable to create directory
Error message
Unable to create directory [{0}] What it means
CreateDirectory wraps Directory.CreateDirectory and converts any OS failure (permissions, invalid characters, IO errors) into an InvalidOperationException with the offending path, keeping the original exception as InnerException.
Solutions
- Check/fix write permissions on the parent directory
- Ensure the path does not point to an existing file; delete or rename it
- Inspect the InnerException for the exact OS error
- Verify the URL resolves to a valid local path (base path set correctly)
Example fix
// before
provider.CreateDirectory(outputUrl);
// after
if (!provider.DirectoryExists(outputUrl))
{
try { provider.CreateDirectory(outputUrl); }
catch (InvalidOperationException ex) { logger.Error($"Cannot create {outputUrl}: {ex.InnerException?.Message}"); throw; }
} Defensive patterns
Strategy: try-catch
Validate before calling
if (File.Exists(localPath)) throw new IOException($"{localPath} exists and is a file");
// ensure parent is writable beforehand
new FileInfo(localPath).Directory?.Refresh(); Try / catch
try { provider.CreateDirectory(url); }
catch (InvalidOperationException ex) { Log(ex.InnerException ?? ex); throw; } Prevention
- Check existing files vs directories before creating
- Verify deployment accounts have write access to target folders
- Never swallow the InnerException — it holds the OS error code
When it happens
Trigger: Calling provider.CreateDirectory(url) where the underlying path cannot be created: no write permission on parent, path is actually an existing file, illegal characters, disk full, or network share unavailable.
Common situations: Creating output folders on read-only deployments, sandboxed environments without write access, or when the path collides with an existing file.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- Directory already exists.
- A file path cannot end with with directory char '\' or '/'…
- Base path must be absolute, got
- Base path must be non-empty (use null for passthrough).
- Build manifest [ ] must exist
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/f0f0049d1b9a4733.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.IO/FileSystemProvider.cs:83
}
public override bool DirectoryExists(string url)
{
var path = ConvertUrlToFullPath(url);
return Directory.Exists(path);
}
/// <inheritdoc/>
public override void CreateDirectory(string url)
{
var path = ConvertUrlToFullPath(url);
try
{
Directory.CreateDirectory(path);
}
catch (Exception ex)
{
throw new InvalidOperationException("Unable to create directory [{0}]".ToFormat(path), ex);
}
}
/// <inheritdoc/>
public override bool FileExists(string url)
{
return File.Exists(ConvertUrlToFullPath(url));
}
public override long FileSize(string url)
{
var fileInfo = new FileInfo(ConvertUrlToFullPath(url));
return fileInfo.Length;
}
/// <inheritdoc/>
public override void FileDelete(string url)
{View on GitHub (pinned to 96fad776d2)