Flow-Launcher/Flow.Launcher · error · DirectoryNotFoundException
Source directory does not exist or could not be found: {sour
Error message
Source directory does not exist or could not be found: {sourcePath} What it means
Thrown as DirectoryNotFoundException from the CopyAll extension method when DirectoryInfo(sourcePath).Exists is false. The check runs before any copy attempt, so no partial state is created. It is the entry-point guard ensuring the source tree exists before recursively copying files and subdirectories to targetPath.
Source
Thrown at Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs:34
public static class FilesFolders
{
private const string FileExplorerProgramName = "explorer";
/// <summary>
/// Copies the folder and all of its files and folders
/// including subfolders to the target location
/// </summary>
/// <param name="sourcePath"></param>
/// <param name="targetPath"></param>
/// <param name="messageBoxExShow"></param>
public static void CopyAll(this string sourcePath, string targetPath, Func<string, MessageBoxResult> messageBoxExShow = null)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourcePath);
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourcePath);
}
try
{
DirectoryInfo[] dirs = dir.GetDirectories();
// If the destination directory doesn't exist, create it.
if (!Directory.Exists(targetPath))
{
Directory.CreateDirectory(targetPath);
}
// Get the files in the directory and copy them to the new location.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
string temppath = Path.Combine(targetPath, file.Name);View on GitHub (pinned to 7fc63b07bb)
Solutions
- Verify Directory.Exists(sourcePath) before calling CopyAll and surface a clear message to the user if not.
- Check the configured source directory value for typos, missing variables, or wrong casing.
- For network/removable sources, confirm the drive is connected and share is reachable.
- If the source should exist, recreate it from a known-good copy or installer.
Example fix
// before
DirectoryInfo dir = new DirectoryInfo(sourcePath);
if (!dir.Exists)
throw new DirectoryNotFoundException("Source directory does not exist or could not be found: " + sourcePath);
// caller guard before invoking
if (!Directory.Exists(sourcePath))
{
messageBoxExShow?.Invoke($"Source not found: {sourcePath}");
return;
} Defensive patterns
Strategy: validation
Validate before calling
if (!Directory.Exists(sourcePath))
{ messageBoxExShow?.Invoke($"Source directory not found: {sourcePath}"); return; } Type guard
null
Try / catch
try { sourcePath.CopyAll(targetPath, messageBoxExShow); }
catch (DirectoryNotFoundException ex) { messageBoxExShow?.Invoke(ex.Message); } Prevention
- Pre-check Directory.Exists(sourcePath) before calling CopyAll.
- Validate configured source paths for typos and variable interpolation.
- For network/removable sources, confirm connectivity before copying.
- Recreate missing template directories from a known-good source.
When it happens
Trigger: CopyAll invoked with a sourcePath that doesn't exist on disk; a relative sourcePath resolved against an unexpected current directory; the source was deleted between the caller's existence check and the call; the source is on a removable/network drive that was disconnected; a typo in the configured source path.
Common situations: Plugin/command copies from a configured template directory that the user moved or never created; portable-mode path misconfiguration; backup/sync tools that deleted the source; network share dropped between listing and copy; a path with a typo or wrong variable interpolation.
Related errors
- Plugin {newPlugin.ID} zip file not found at {filePath}
- The zip file does not contain a plugin.json file.
- Theme path can't be found <{path}>
- Invalid SVG dimensions: Height must be greater than zero in
- DoublePinyinSchema '{schemaKey}' is invalid or double pinyin
AI-assisted analysis of Flow-Launcher/Flow.Launcher@7fc63b07bb (2026-08-13).
Data as JSON: /api/errors/e2f4bbc67bbb45e0.
Report an issue: GitHub.