C# FileSystemWatcher未为在ffmpeg中打开的文件触发事件

C# FileSystemWatcher未为在ffmpeg中打开的文件触发事件,c#,ffmpeg,C#,Ffmpeg,我试图检查上次使用FileSystemWatcher更改文件大小,但该文件仍在另一个程序ffmpeg.exe中打开的时间。我不知道为什么更改的事件没有被触发。 以下是我的代码: using (var proc = new Process()) { Console.WriteLine("Iniciando gravação da stream:"+url); proc.StartInfo.FileName =

我试图检查上次使用FileSystemWatcher更改文件大小,但该文件仍在另一个程序ffmpeg.exe中打开的时间。我不知道为什么更改的事件没有被触发。 以下是我的代码:

using (var proc = new Process())
            {

                Console.WriteLine("Iniciando gravação da stream:"+url);
                proc.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + @"\ffmpeg.exe";
                proc.StartInfo.Arguments = @"-y -i " + url + @" -ab 32k -ac 1 -ar 11025 " + idStation + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp3";

                proc.StartInfo.RedirectStandardOutput = true;

                proc.StartInfo.RedirectStandardError = true;
                proc.StartInfo.RedirectStandardInput = true;

                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.CreateNoWindow = true;

                proc.EnableRaisingEvents = true;

                proc.Start();

                proc.BeginOutputReadLine();
                proc.BeginErrorReadLine();


                proc.ErrorDataReceived += new DataReceivedEventHandler(CheckOutput);

                FileSystemWatcher fileSizeChecker = new FileSystemWatcher();
                fileSizeChecker.Changed += WatchFile;
                fileSizeChecker.Path = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + @"\" + idStation + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp3");
                fileSizeChecker.Filter = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory + @"\" + idStation + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp3");
                fileSizeChecker.EnableRaisingEvents = true;
                fileSizeChecker.BeginInit();
            }
static void WatchFile(object sender, FileSystemEventArgs e)
    {
        Console.WriteLine(DateTime.Now.ToString("T") + "] Watcher changed!");
    }

从不调用WatchFile。

这里讨论了FileSystemWatcher在这种情况下的行为

文件大小更改事件在文件关闭之前不会触发