I don’t get the abstractions and the terminology 🙁
For example, DirectoryInfo.FullName is defined as the full path of the directory or file, but it’s a string! So is DirectoryInfo.Name, FileInfo.FullName, Path.GetDirectoyName and so on.
This means that in .Net there is no “depth” (or “meat” – my English isn’t so good) for the file system objects. There’s no protection from a type system. I can’t, for example, define two Path objects and ask if one of them is “above” the other – I have to manipulate the strings. I can’t differentiate between a Path that identifies a directory and a path that identifies a file. I can’t do anything!-( Just manipulate strings.
Is this correct (or am I simply missing something). If correct, are there any alternatives?
You should take a look at the
Pathclass and theUriclass.MSDN links:
Path Class
Uri Class
For example with the
Pathclass you have methods to get only the directory, only the filenam or even only the filename without the extension for a given path.With the
Uriclass you have a property to tell you if it’s an absoluteUri(IsAbsoluteUri) and a method to make a relativeUri(MakeRelativeUri). Check the Uri FAQ for further information.Example for traversing a path from top to bottom: