PDA

Click to See Complete Forum and Search --> : CommonDialog Conversion [RESOLVED]


Rattlerr
Jan 30th, 2006, 10:58 PM
I need some help with syntex for the CommonDialog I know "With" isnt used in C# but i'm converting an old VB6 App to the C#.NET 2005


With CommonDialog
.Filename = ""
.DialogTitle = "Load bots List"
.Filter = "All Supported Types|*.txt"
.ShowOpen
If .FileName = "" Then Exit Sub

If someone could help me convert this I'd appreciate it..Been trying too look it up on msdn with no luck..thxs in advance :)

mar_zim
Jan 30th, 2006, 11:39 PM
I haven't done vb6 but as what I've understand I think commondialog class was replace in .net w/ filedialog.

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)
{
if(openFileDialog1.Filename=="")
{
//do something
}
else
{
//do something
}
}