Nicholas, the default file would have an extension of .DAT, and would be the
routine I want to run first.
The program is an RichText editor that opens and formats the DAT file
normally, and can also open;
RTF, TXT, LOG files as needed.
The name of the DAT always begins with OCG, the rest would be dependent on
what ever date and hour is current.
So the bottom line is that the name is not static.(rambled didn't I).
Thanks,
"Nicholas Paldino [.NET/C# MVP]" wrote:
Brian,
If you have the full path to the file, then you can call the static
GetExtension method on the Path class in the System.IO namespace to get the
extension. Then, you can call ToLower on it and switch on that:
// The filename.
string filename = ...;
// The extension.
string extension = Path.GetExtension(filename).ToLower();
// Switch on the extension.
switch (extension
{
case ".dat":
// Do Something
break;
case ".rtf":
// Do something else.
break;
}
You might want to put a "default" statement as well in there to handle
cases where extension is not any of the ones you specify.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Brian Cook" <br********@bnsf.comwrote in message
news:F2**********************************@microsof t.com...
New programmer lost!!!
I need some help with a switch/Case statement;
I need to use OpenFileDialog to open a file,
If the file extension is .dat, then do x.
If the file extension is .rtf, then do y.
if the file extension is .txt, then do z.
Thanks,
Brian