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, no registration required.

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
1  
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 –  QuiteNothing Apr 3 '12 at 14:51
1  
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 –  QuiteNothing Apr 3 '12 at 14:56
add comment

4 Answers

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.... –  QuiteNothing Apr 3 '12 at 17:51
add comment

How about calling your method GetPathComponents(string path)?

share|improve this answer
1  
+1 - Components is better than my suggestion –  Ozz 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.. –  QuiteNothing Apr 3 '12 at 15:05
1  
@Omkar panhalkar: I disagree (see this article). However, use whatever you prefer. :) –  Bernard Apr 3 '12 at 15:16
add comment

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... :) –  QuiteNothing Apr 3 '12 at 15:10
add comment

I'd say File path parts would work.

share|improve this answer
add comment

Your Answer

 
discard

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.