nwoltman / srt-to-vtt-cl

A command line tool that converts subtitle files from SubRib (.srt) format to WebVTT (.vtt) format
MIT License
95 stars 11 forks source link

Trying to run it from c# #7

Closed SalmaTofaily closed 6 years ago

SalmaTofaily commented 6 years ago

Hello, I tried to run the code from c# but the process did not end and the file was not converted. this is a portion of the code used. Do you have any idea?

  public static void test7()// It did not end, no error but no file and still waiting
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName = "cmd.exe";
            startInfo.Arguments = "srt-vtt a.srt ";
            startInfo.WorkingDirectory = @"C:\Users\Salma\Desktop\test\";
            startInfo.UseShellExecute = true;
            process.StartInfo = startInfo;
            process.Start();
            process.WaitForExit();
            process.Close();

            var t = process.HasExited;
        }
nwoltman commented 6 years ago

It works if you change these lines:

startInfo.FileName = "cmd.exe";
startInfo.Arguments = "srt-vtt a.srt ";

to:

startInfo.FileName = "srt-vtt.exe";
startInfo.Arguments = "a.srt";

as long as srt-vtt.exe is in your C:\Users\Salma\Desktop\test\ folder.

Also, accessing process.HasExited after calling process.Close() will cause an error since Process.Close() "Frees all the resources that are associated with this component."

nwoltman commented 6 years ago

@SalmaTofaily Is this still an issue for you? Has my previous comment helped at all?

nwoltman commented 6 years ago

Closing due to inactivity.