예제 #1
0
        private void openSelectedFile()
        {
            // EXTRACT FILE IN TEMP DIRECTORY
            DataGridViewSelectedRowCollection rowsSelection = dgvFiles.SelectedRows;

            if (rowsSelection.Count > 0)
            {
                icomp.extractFile(rowsSelection[0].Cells[5].Value.ToString(), icomp.TempPath);
                string tempFile = icomp.TempPath + rowsSelection[0].Cells[5].Value.ToString();
                try
                {
                    // OPEN THE FILE WITH THE ASSOCIATED PROGRAM
                    System.Diagnostics.Process.Start(tempFile);
                }
                catch (System.ComponentModel.Win32Exception ex)
                {
                    // IF AN EXCEPTION IS FIRED OPEN THE FILE WITH THE DEFAULT EDITOR
                    string defaultEditor = IniManager.IniGet(IniManager.iniFilePath, "DEFAULT", "defaultEditor", "");
                    if (defaultEditor != "")
                    {
                        CommonFunctions.runApp(defaultEditor, tempFile);
                    }
                }
            }
        }
예제 #2
0
파일: Icomp.cs 프로젝트: JON4CL/zViewer
        //
        private string[] getRunBuffer(string arguments)
        {
            string[] buffers = new string[2];
            buffers[0] = "";
            buffers[1] = "";
            // WRITE LOG FILE
            string writeLogFile = IniManager.IniGet(IniManager.iniFilePath, "DEFAULT", "writeLogFile", "NO");

            if (writeLogFile.ToUpper() == "YES")
            {
                string defaultLogFileName = Application.StartupPath + @"\log.txt";
                string logFileName        = IniManager.IniGet(IniManager.iniFilePath, "DEFAULT", "fileName", defaultLogFileName);
                CommonFunctions.saveLogFile(logFileName, icompPath + "|" + arguments);
            }
            //
            ProcessStartInfo processStartInfo = new ProcessStartInfo(icompPath, arguments);

            processStartInfo.UseShellExecute        = false;
            processStartInfo.ErrorDialog            = false;
            processStartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            processStartInfo.CreateNoWindow         = true;
            processStartInfo.RedirectStandardError  = true;
            processStartInfo.RedirectStandardInput  = true;
            processStartInfo.RedirectStandardOutput = true;
            //
            Process process = new Process();

            process.StartInfo = processStartInfo;
            //
            bool         processStarted;
            StreamWriter inputWriter;
            StreamReader outputReader;
            StreamReader errorReader;

            //
            try
            {
                processStarted = process.Start();
                inputWriter    = process.StandardInput;
                outputReader   = process.StandardOutput;
                errorReader    = process.StandardError;

                //Display the result
                buffers[0] = outputReader.ReadToEnd();
                buffers[1] = errorReader.ReadToEnd();

                process.WaitForExit();
            }
            catch (Exception ex)
            {
                buffers[1] = "MESSAGE: " + ex.Message.ToString() + Environment.NewLine +
                             "ICOMP PATH: " + icompPath + Environment.NewLine +
                             "ARGUMENTS: " + arguments;
            }
            //
            return(buffers);
        }