Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I want to give nice name to my function while returns drive, directory and file. Can you please suggest a good abstract name for this trio?

This is the function.

  static IEnumerable<string> GetDriveDirectoriesAndFile(string path)
     if (path.Contains('/'))
        path = path.Replace('/', '\\');
     if (path.Contains('\\'))
        return path.Split('\\');
     return null;

Thanks, Omkar

share|improve this question
will it return the whole thing at once, like on windows "C:/programs/something"? This would mostly be called a file_path. –  thorsten müller Apr 3 '12 at 14:50
It takes path and return IEnumerable<string> which contains C:,programs,something.txt like that.. thanks –  om471987 Apr 3 '12 at 14:51
How about "FileSystemObjects"? It's the only term I can think of that covers them all. –  FrustratedWithFormsDesigner Apr 3 '12 at 14:54
Yes perfectly makes sense.. Plz add it as answer so I can tick it as accepted –  om471987 Apr 3 '12 at 14:56
AbstractNamingPathVisitorAdapterContext - sorry, I had to poke fun at the over-sophisticated names that come from overuse of design patterns. Path element, path part or path component are all fine. –  Brandon Jun 2 '14 at 0:47

4 Answers 4

up vote 4 down vote accepted

Since it looks like you are using .NET, if possible I would suggest using the terminology in the System.IO.Path class:

  • Root (Drive letter such as C:\ or UNC such as \server\share)
  • Directory Name
  • File Name

Also, if possible, I would suggest using the Path, FileInfo, and DirectoryInfo classes when working with file system paths, rather then attempting to do the splitting, combining, and parsing on your own.

share|improve this answer
Bingo... Exactly what looking for... In control systems such solutions are called feed Forward systems.... –  om471987 Apr 3 '12 at 17:51

How about calling your method GetPathComponents(string path)?

share|improve this answer
+1 - Components is better than my suggestion –  jmo21 Apr 3 '12 at 15:04
File itself cannot be a component of path. These all can be categorized under file system objects... FileSystemObject is closer to the correct nam right now for me.. –  om471987 Apr 3 '12 at 15:05
@Omkar panhalkar: I disagree (see this article). However, use whatever you prefer. :) –  Bernard Apr 3 '12 at 15:16

I'm going to suggest "FileSystemObjects", Or if you want to shorten it: "FSObjects", or "FSOs", or some variant of that.

share|improve this answer
Thanks frustrated person...LOL... Thanks a lot.. I decided to go with GetFileSystemObjects... :) –  om471987 Apr 3 '12 at 15:10

I'd say File path parts would work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.