All pastes #836123 Raw Edit

frmReadDVD startProc

public text v1 · immutable
#836123 ·published 2007-12-29 06:35 UTC
rendered paste body
        private void startProc(object state)
        {
            try
            {
                //TODO: Consider capturing the Process Output directly and having the parser work 
                //      from a string instead of a StreamReader, or converting the string to a 
                //      StreamReader

                string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
                string dvdInfoPath = Path.Combine(
                                    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                    @"Temp\dvdinfo.dat");
                
                // Make we don't pick up a stale dvdinfo.dat (and that we have rights to the file)
                if (File.Exists(dvdInfoPath))
                    File.Delete(dvdInfoPath);

                string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 -v >""{2}"" 2>&1""", handbrakeCLIPath, inputFile, dvdInfoPath);
                
                using (Process hbproc = Process.Start("CMD.exe", strCmdLine))
                {
                    hbproc.WaitForExit();
                    // TODO: Verify exit code if the CLI supports it properly
                }

                if (!File.Exists(dvdInfoPath))
                {
                    throw new Exception("Unable to retrieve the DVD Info. dvdinfo.dat missing.");
                }

                using (StreamReader sr = new StreamReader(dvdInfoPath))
                {
                    thisDvd = Parsing.DVD.Parse(sr);
                }

                updateUIElements();
            }
            catch (Exception exc)
            {
                MessageBox.Show("frmReadDVD.cs - startProc " + exc.ToString());
            }

        }


Fragment for Main's Experation time code:
            // Development Code Expiry.
            // Remember to comment out on public release!!!

            if (DateTime.Now > DateTime.Parse("2/1/2008")) { MessageBox.Show("Sorry, This development build of Handbrake has expired."); return; }