CUDA_Manager.Form1.batBuilder C# (CSharp) Method

batBuilder() private method

private batBuilder ( string key, bool import, string source ) : void
key string
import bool
source string
return void
        private void batBuilder(string key, bool import, string source)
        {
            string inter = "0";
            if (chkInter.Checked)
                inter = "1";

            string core = "2";
            if (CBcores.SelectedIndex == 1)
                core = "0";
            else if (CBcores.SelectedIndex == 2)
                core = "1";

            string command = "cudaminer.exe " + tbConfig.Text + " -i " + inter + " -H " + core + " -o " + TBstrat.Text + " -O " + tbWorker.Text + ":" + TBpass.Text;

            try
            {
                if (import && File.Exists(source))
                {
                    string[] loadbat = File.ReadAllLines(source);
                    StreamWriter newbat = new StreamWriter(minepath + key + ".bat");
                    foreach (string line in loadbat)
                    {
                        string[] sepline = line.Split('\\');
                        if (sepline[sepline.Count() - 1].ToLower().StartsWith("cudaminer"))
                            newbat.WriteLine(command);
                        else
                            newbat.WriteLine(line);
                    }
                    newbat.Close();
                }
                else
                    File.WriteAllText(minepath + key + ".bat", command);
            }
            catch { MessageBox.Show("Unable to create miner.\r\nTry running as Administrator."); }
        }