BCUninstaller/Bulk-Crap-Uninstaller · error · InvalidDataException
The uninstall list file is empty.
Error message
The uninstall list file is empty.
What it means
After opening the file for read, ReadFromFile checks stream.Length == 0 and throws InvalidDataException 'The uninstall list file is empty.' An empty file would cause the XmlSerializer to throw a generic InvalidOperationException; the explicit length check produces a meaningful, user-presentable error before deserialisation.
Source
Thrown at source/UninstallTools/Lists/UninstallList.cs:93
}
if (!included.HasValue)
return excluded.HasValue ? true : null;
return included.Value;
}
public bool Enabled { get; set; } = true;
public static UninstallList ReadFromFile(string fileName)
{
if (string.IsNullOrWhiteSpace(fileName))
throw new ArgumentException("File name cannot be empty.", nameof(fileName));
var serializer = new XmlSerializer(typeof (UninstallList));
using (var stream = File.OpenRead(fileName))
{
if (stream.Length == 0)
throw new InvalidDataException("The uninstall list file is empty.");
try
{
return Deserialize(serializer, XmlReader.Create(stream, ReaderSettings));
}
catch (Exception ex) when (ex is InvalidOperationException or XmlException)
{
if (!stream.CanSeek)
throw CreateInvalidDataException(ex);
stream.Position = 0;
using var textReader = new StreamReader(stream, Encoding.UTF8, true, 1024, true);
var trimmedContents = textReader.ReadToEnd().TrimStart('\uFEFF', '\u200B', ' ', '\t', '\r', '\n');
if (trimmedContents.Length == 0)
throw CreateInvalidDataException(ex);
using var stringReader = new StringReader(trimmedContents);
tryView on GitHub (pinned to 608321de98)
Solutions
- Check new FileInfo(fileName).Length > 0 before calling ReadFromFile and prompt the user.
- Restore from a backup (.bak) if the file is unexpectedly empty.
- Ensure the writer's save path opens with FileShare.None and writes atomically (write to .tmp then File.Move) so an interrupted save never leaves a 0-byte target.
Example fix
// before
var list = UninstallList.ReadFromFile(path);
// after
if (new FileInfo(path).Length == 0)
throw new InvalidDataException($"'{path}' is empty; the save may have been interrupted.");
var list = UninstallList.ReadFromFile(path); Defensive patterns
Strategy: validation
Validate before calling
var info = new FileInfo(fileName);
if (!info.Exists || info.Length == 0)
throw new InvalidDataException($"'{fileName}' is missing or empty.");
var list = UninstallList.ReadFromFile(fileName); Type guard
null
Try / catch
try { list = UninstallList.ReadFromFile(path); }
catch (InvalidDataException ex) when (ex.Message.Contains("empty"))
{
list = RestoreFromBackup(path);
} Prevention
- Write list files atomically (temp file + File.Move) so an interrupted save never leaves a 0-byte file.
- Keep a .bak copy of the previous list and restore on empty-file errors.
- Confirm cloud-sync clients have finished downloading before opening.
When it happens
Trigger: Pointing ReadFromFile at a zero-byte file: a truncated download, a file created by 'touch' or an interrupted save, or a placeholder file written by another tool.
Common situations: An uninstall list file was partially written and the process crashed leaving a 0-byte file; a sync/cloud client has not finished downloading the file; antivirus quarantined and emptied the file.
Related errors
- The file does not contain an uninstall list. Expected root e
- The uninstall list file could not be deserialized.
- File name cannot be empty.
- List is empty
- Value cannot be null or empty
AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13).
Data as JSON: /api/errors/56304b674484accf.
Report an issue: GitHub.