There are cases where we want to ensure that the filename entered by the user has a valid extension of your choice, say .XLS, .ZIP. Sometimes user may not enter extension, or may enter wrong extension like .XLA, .ZIL. In such cases, here is a simple tip where we need not check how user enters the file name.
string orgFileName1 = @"d:\test\abc.xla";
string orgFileName2 = @"d:\test\abc";
string newFileName1 = System.IO.Path.ChangeExtension(orgFilename1, "xls");
string newFileName2 = System.IO.Path.ChangeExtension(orgFilename2, "xls");
Console.WriteLine(newFileName1);
Console.WriteLine(newFileName2);
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.