【问题标题】:FileSystemWatcher not firing events for files opened in ffmpegFileSystemWatcher 不会为在 ffmpeg 中打开的文件触发事件
【发布时间】:2018-02-02 13:54:42
【问题描述】:

我正在尝试检查文件上次使用 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 永远不会被调用。

【问题讨论】:

    标签: c# ffmpeg


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多