netchx/netch · error · MessageException
Update file top-level directory not exist
Error message
Update file top-level directory not exist
What it means
After a successful extraction the updater requires the archive to contain a single top-level directory named exactly 'Netch' (it does Path.Combine(extractPath, "Netch")). If that directory does not exist, the package layout is wrong and the update is aborted. This guard prevents files from being flattened directly into the install root, which would corrupt the install.
Source
Thrown at Netch/Services/Updater.cs:42
_tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(_tempDirectory);
}
#region Apply Update
internal void ApplyUpdate()
{
var extractPath = Path.Combine(_tempDirectory, "extract");
int exitCode;
if ((exitCode = Extract(extractPath)) != 0)
throw new MessageException(i18N.Translate($"7za unexpectedly exited. ({exitCode})"));
// update archive file must have a top-level directory "Netch"
var updateDirectory = Path.Combine(extractPath, "Netch");
if (!Directory.Exists(updateDirectory))
throw new MessageException(i18N.Translate("Update file top-level directory not exist"));
// {_tempDirectory}/extract/Netch/Netch.exe
var updateMainProgramFilePath = Path.Combine(updateDirectory, "Netch.exe");
if (!File.Exists(updateMainProgramFilePath))
throw new MessageException(i18N.Translate($"Update file main program not exist"));
MarkFilesOld();
// move {tempDirectory}\extract\Netch to install folder
MoveFilesOver(updateDirectory, InstallDirectory);
}
private void MarkFilesOld()
{
var keepDirFullPath = KeepDirectories.Select(d => Path.Combine(InstallDirectory, d)).ToImmutableList();
foreach (var file in Directory.GetFiles(InstallDirectory, "*", SearchOption.AllDirectories))
{View on GitHub (pinned to 9d99eb1c5a)
Solutions
- Use the official update package whose top-level folder is 'Netch'.
- Re-download from the official source.
- If building locally, ensure the archive root directory is named 'Netch'.
- Open the archive with 7-Zip/Explorer to confirm the folder layout before applying.
Example fix
// before
var updateDirectory = Path.Combine(extractPath, "Netch");
if (!Directory.Exists(updateDirectory))
throw new MessageException(i18N.Translate("Update file top-level directory not exist"));
// after - accept the single top-level dir, or require the 'Netch' name
var topDirs = Directory.GetDirectories(extractPath);
var updateDirectory = topDirs.Length == 1 ? topDirs[0] : Path.Combine(extractPath, "Netch");
if (!Directory.Exists(updateDirectory))
throw new MessageException("Update archive must contain a top-level 'Netch' directory"); Defensive patterns
Strategy: validation
Validate before calling
// After extraction, sanity-check the layout
var root = Path.Combine(extractPath, "Netch");
if (!Directory.Exists(root))
throw new MessageException("Update package layout invalid; expected a top-level 'Netch' folder."); Try / catch
try { updater.ApplyUpdate(); }
catch (MessageException ex) when (ex.Message.Contains("top-level directory"))
{
Log.Error("Bad update package layout: {Msg}", ex.Message);
Global.MainForm.NotifyTip("This update package is malformed. Use the official release.");
} Prevention
- In the release script, assert the archive's first entry is a 'Netch' directory.
- Document the required archive layout for contributors.
- Add a CI check that opens the published archive and verifies the root folder name.
When it happens
Trigger: The release archive was packaged without its 'Netch' root folder (files at archive root), or with a differently-named root directory (e.g. 'Netch-x64', 'netch', or a version-numbered folder).
Common situations: Maintainer repackaged the release incorrectly; the updater was pointed at a third-party or wrong archive; a cross-platform packaging step produced a versioned folder name.
Related errors
AI-assisted analysis of netchx/netch@9d99eb1c5a (2026-08-13).
Data as JSON: /api/errors/2f7efa0345602383.
Report an issue: GitHub.