OFD= OpenFileDialog
I am setting up for 2 buttons for creating a ZIP file from folder and extracting a ZIP file to folder. The problem is that OpenFileDialog doesn't have SelectedPath. What should I use instead to make the second button work?
private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog obj = new FolderBrowserDialog(); //Mappa böngészo DialogResult result = obj.ShowDialog(); //Mappa kiválasztása if (result==DialogResult.OK && !string.IsNullOrWhiteSpace(obj.SelectedPath)) { string[] folder = obj.SelectedPath.Split('\\'); string foldertobezip = folder[folder.Length - 1]; pathtofolder = obj.SelectedPath; zipfolder = string.Join(@"\", folder.Take(folder.Length - 1)) + @"\" + foldertobezip + ".zip"; ZipFile.CreateFromDirectory(pathtofolder, zipfolder); //Elkészül a ZIP file MessageBox.Show("Zip file is created!"); } } private void button2_Click(object sender, EventArgs e) { OpenFileDialog obj = new OpenFileDialog(); //Mappa böngészo DialogResult result = obj.ShowDialog(); //Mappa kiválasztása if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(obj.SelectedPath)) { string[] folder = obj.SelectedPath.Split('\\'); string foldertobezip = folder[folder.Length - 1]; pathtofolder = obj.SelectedPath; zipfolder = string.Join(@"\", folder.Take(folder.Length - 1)) + @"\" + foldertobezip + ".zip"; ZipFile.ExtractToDirectory(zipfolder, pathtofolder); MessageBox.Show("Folder file is created!"); } }