Uahh/ToastFish · warning
ex.Message
Error message
ex.Message
What it means
isFileWave validates whether a file is a WAV file by reading its header through a FileStream; an IOException (file locked, device error, disk full, network path failure) during that read is caught and shown as a raw message box. It is a low-level I/O failure, not a format problem — a non-WAV file simply returns isWave=false without any exception.
Solutions
- Retry after closing applications that may hold the file open (media players, editors)
- Check the file exists and is on an available local disk before calling
- Release/Dispose any FileStream you opened previously on the same path before probing it
- Catch IOException explicitly in caller code and fall back to SpeechSynthesizer playback instead of failing
Example fix
// before
try { isWave = CheckWaveHeader(fs); }
catch (IOException ex) { MessageBox.Show(ex.Message); }
// after
try { isWave = CheckWaveHeader(fs); }
catch (IOException ex)
{
Debug.WriteLine($"WAV probe failed for {path}: {ex.Message}");
isWave = false; // caller falls back to TTS
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!File.Exists(path)) return false;
try { using File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); return true; }
catch (IOException) { return false; } Type guard
null
Try / catch
try { isWave = isFileWave(path); }
catch (IOException ex) { Debug.WriteLine($"WAV probe IO error: {ex.Message}"); isWave = false; }
catch (Exception ex) { Debug.WriteLine(ex.Message); isWave = false; } Prevention
- Close all FileStreams on the file before probing it
- Retry once after a short delay if the file may still be downloading
- Copy network/removable-media files to a local temp path first
- Fall back to TTS (SpeechSynthesizer) instead of failing the playback
When it happens
Trigger: PlayMp3/isFileWave is called on an mp3/wav path while another process (player, antivirus, indexer) holds the file open exclusively, the file is on an unavailable network/USB drive, or the stream read hits a disk error mid-header-read.
Common situations: Audio file still being written by a download when playback is attempted; removable media unplugged mid-scan; Windows file locking after a crashed player; long-path or permission issues surfacing as IOException.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- ex.Message, "Excel read error"
- 导入失败,Excel格式不正确或Excel文件损坏
- 程序已经在运行了,不能运行两次。\n如果右下角软件已经退出,请在任务管理器中结束ToastFish任务。
- 卡题出错!
- $"重置 出错!
AI-assisted analysis of Uahh/ToastFish@2508784a66 (2026-09-15).
Data as JSON: /api/errors/24755a2309d36e05.
Report an issue: GitHub.
Appendix: source
Thrown at Model/Mp3/PlayMp3.cs:177
// FileStream fs = new FileStream(path, FileMode.Open);
//fs.Seek(-128, SeekOrigin.End);
fs.Read(b, 0, 16);
//Set flag
String sFlag = System.Text.Encoding.Default.GetString(b, 0, 4).ToUpper();
String sType = System.Text.Encoding.Default.GetString(b, 8, 4).ToUpper();
if (sFlag.CompareTo("RIFF") == 0) isSet1 = true;
if (sType.CompareTo("WAVE") == 0) isSet2 = true;
if (isSet1 && isSet2)
{
isWave = true;
}
fs.Close();
fs.Dispose();
}
catch (IOException ex)
{
System.Windows.MessageBox.Show(ex.Message);
}
return isWave;
}
}
public class APIClass
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
string lpszLongPath,
string shortFile,
int cchBuffer
);
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,View on GitHub (pinned to 2508784a66)