CommonDialog Conversion [RESOLVED]
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
VB Code:
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 :)
Re: CommonDialog Conversion
I haven't done vb6 but as what I've understand I think commondialog class was replace in .net w/ filedialog.
Code:
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
}
}