Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Bechir BejaouiPosted Jul 18, 2008, 11:05 AM
if you want to get the extension of a given file without having to use the String class functions for example you can use the GetExtension static method of the class path first you define a string that represents your file path string oPath = @"C:\myFile.txt"; then the GetExtention path will return a string that represent the file extention string extention = Path.GetExtension(oPath);. Of Corse, if you want to substitute the extention for exemple the *.doc by *.docx then use ChangeExtension instead of the GetExtension one. ChangeExtension is also a static method of the Path class . If you have any question about this please send me back. I send you a smal project accoring to this
Mike GoldPosted Jul 18, 2008, 10:13 AM
wasn't clear from this entry what to do. Is this what you meant to type? string theExtension = Path.GetExtension(thePath);