private void openDialog() { string filePath = ""; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { string CombinedPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\Results\\"); openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; //openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; openFileDialog.InitialDirectory = System.IO.Path.GetFullPath(CombinedPath); if (openFileDialog.ShowDialog() == DialogResult.OK) { filePath = openFileDialog.FileName; List <Hero> hero = Ultilities.ReadSerializedObjectFile <List <Hero> >(filePath); //Save the hero to program Program.character = hero[0]; //Write it into full label for all screen updateLayout(); } } }
public void loadFile() { string filePath = ""; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { //string CombinedPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\Results\\"); openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; //openFileDialog.FilterIndex = 2; //openFileDialog.RestoreDirectory = true; //openFileDialog.InitialDirectory = System.IO.Path.GetFullPath(CombinedPath); if (openFileDialog.ShowDialog() == DialogResult.OK) { filePath = openFileDialog.FileName; Product product = Ultilities.ReadSerializedObjectFile <Product>(filePath); Program.product = product; LoadData(); } } }