예제 #1
0
        private void tsmi_load_console_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists("Recieved"))
            {
                Directory.CreateDirectory("Recieved");
            }

            if (Vars.isConnected)
            {
                if (File.Exists(Folders.Recieved + "\\" + FileNames.launchINI))
                {
                    File.Delete(Folders.Recieved + "\\" + FileNames.launchINI);
                }
                List <string> FoundDrives = new List <string>();
                if (Xbox.GetDrives().Length > 1)
                {
                    foreach (string drive in Xbox.GetDrives())
                    {
                        try {
                            Vars.xbCon.ReceiveFile(Folders.Recieved + "\\" + FileNames.launchINI, drive + ":\\" + FileNames.launchINI);
                            FoundDrives.Add(drive);
                        } catch { continue; }
                    }
                }

                if (FoundDrives.Count > 1)
                {
                    File.Delete(Folders.Recieved + "\\" + FileNames.launchINI);
                    frm_sub_edit_ini sub_ini = new frm_sub_edit_ini(FoundDrives.ToArray());
                    if (sub_ini.ShowDialog() == DialogResult.OK)
                    {
                        try {
                            if (Vars.isConnected)
                            {
                                Vars.xbCon.ReceiveFile(Folders.Recieved + "\\" + FileNames.launchINI, this.chosen_drive + ":\\" + FileNames.launchINI);
                                using (StreamReader sr = new StreamReader(Folders.Recieved + "\\" + FileNames.launchINI)) {
                                    rtb_ini_editor.Text = sr.ReadToEnd();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Not connected to console.");
                            }
                        } catch { MessageBox.Show("There was an error recieving file! Please try again!"); }
                    }
                }
                else
                {
                    File.Delete(Folders.Recieved + "\\" + FileNames.launchINI);
                    this.chosen_drive = FoundDrives[0];
                    try {
                        if (Vars.isConnected)
                        {
                            Vars.xbCon.ReceiveFile(Folders.Recieved + "\\" + FileNames.launchINI, this.chosen_drive + ":\\" + FileNames.launchINI);
                            using (StreamReader sr = new StreamReader(Folders.Recieved + "\\" + FileNames.launchINI)) {
                                rtb_ini_editor.Text = sr.ReadToEnd();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Not connected to console.");
                        }
                    } catch { MessageBox.Show("There was an error recieving file! Please try again!"); }
                }
            }
            else
            {
                MessageBox.Show("Connect to your console!");
            }
        }