This is going to sound like a real newbie post. But I keep forgetting this particular bit of information and I keep having to write little throw away applications to find out the answer. FileInfo has a number of properties and the MSDN description on them are almost next to useless.
Given the file C:folderfile.ext
- FileInfo.Name returns “file.ext”
- FileInfo.FullName returns “C:\folderfile.ext”
- FileInfo.Extension returns “.ext” (note the dot suffix)
- FileInfo.DirectoryName returns “C:\folder”
- An exception is if the file is in the root directory. The result would be something like “C:\” with the trailing slash will be returned.
So there we have it. The things that I keep forgetting about
FileInfo that MSDN just does not explain (except the Extension property, it at least does explain that one)
NOTE: This was rescued from the Google Cache. The original was dated Monday, 28th March 2005.