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);
                    try

View on GitHub (pinned to 608321de98)

Solutions

  1. Check new FileInfo(fileName).Length > 0 before calling ReadFromFile and prompt the user.
  2. Restore from a backup (.bak) if the file is unexpectedly empty.
  3. 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

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


AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13). Data as JSON: /api/errors/56304b674484accf. Report an issue: GitHub.