Is there a more correct type for passing in the file path and file name to a method

Posted by Rihan Meij on Stack Overflow See other posts from Stack Overflow or by Rihan Meij
Published on 2010-05-27T06:57:34Z Indexed on 2010/05/27 7:01 UTC
Read the original article Hit count: 230

Filed under:
|
|
|
|

Hi

What I mean by this question is, when you need to store or pass a URL around, using a string is probably a bad practice, and a better approach would be to use a URI type. However it is so easy to make complex things more complex and bloated.

So if I am going to be writing to a file on disk, do I pass it a string, as the file name and file path, or is there a better type that will be better suited to the requirement?

This code seems to be clunky, and error prone? I would also need to do a whole bit of checking if it is a valid file name, if the string contains data and the list goes on.

private void SaveFile(string fileNameAndPath) { //The normal stuff to save the file }

© Stack Overflow or respective owner

Related posts about c#

Related posts about best-practices