Пример #1
0
        public void ExecuteCommand(string cygwinLocation, OutputLine line, Action <OutputLine> callBack)
        {
            Process proc  = new Process();
            string  stOut = "";

            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardInput  = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            proc.StartInfo.CreateNoWindow         = true;
            proc.StartInfo.FileName  = cygwinLocation;
            proc.StartInfo.Arguments = "-i -l";

            proc.Start();

            StreamWriter sw = proc.StandardInput;
            StreamReader sr = proc.StandardOutput;
            StreamReader se = proc.StandardError;

            sw.AutoFlush = true;

            string cmd = "ls -lh";

            sw.WriteLine(cmd);

            //while (true)
            //{
            //    //if(sr.Peek() >= 0)
            //    {
            //        Console.WriteLine("sr.Peek = " + sr.Peek());
            //        Console.WriteLine("sr = " + sr.ReadLine());
            //    }

            //    if (se.Peek() >= 0)
            //    {
            //        Console.WriteLine("se.Peek = " + se.Peek());
            //        Console.WriteLine("se = " + se.ReadLine());
            //    }
            //}


            if (checkBox1.Checked || !File.Exists(line.Path))
            {
                sw.WriteLine(line.Command);
            }

            sw.Close();
            sr.Close();

            proc.WaitForExit();
            proc.Close();
        }
Пример #2
0
        private void GenerateNeucomFile(string classFileLocation, OutputLine physionetFile, string destination)
        {
            if (!File.Exists(classFileLocation))
            {
                File.Create(classFileLocation).Close();
            }

            using (StreamWriter classFile = new StreamWriter(classFileLocation, true))
            {
                string filePath = Path.Combine(destination, string.Format("sam{0}_eeg.csv", physionetFile.Count));
                using (StreamWriter outputFile = new StreamWriter(filePath))
                {
                    foreach (var line in File.ReadAllLines(physionetFile.Path).Skip(2))
                    {
                        outputFile.WriteLine(line.Remove(0, line.IndexOf(',') + 1));
                    }
                }

                int cat = GetClass(physionetFile.Path);
                classFile.WriteLine(cat);
                classFile.Close();
            }
        }