Головна‎ > ‎C# WinForms‎ > ‎

Вікно вибору файлу

// using System.IO;


OpenFileDialog openFileDialog1 = new OpenFileDialog(); 

// openFileDialog1.InitialDirectory = "c:\\"; 
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2 ; 
openFileDialog1.RestoreDirectory = true ;

if(openFileDialog1.ShowDialog() == DialogResult.OK) {

     // openFileDialog1.FileName

}


// using System.IO;


SaveFileDialog saveFileDialog1 = new SaveFileDialog(); 

saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";  
saveFileDialog1.FilterIndex = 2 ; 
saveFileDialog1.RestoreDirectory = true ; 

if(saveFileDialog1.ShowDialog() == DialogResult.OK) { 

     // saveFileDialog1.FileName

}



Environment.NewLine;