It's very important to read the documentation of this method before actually using it.  A common misunderstanding of this method is that it will throw if the path does not exist.  If Path.GetFullPath() discovers that the directory does exists it will make sure the user has access to the path.  In the abscence of a directory it will skip the check and just return the canonicalized path. 

This produces some interesting behavior with relative paths.  Say that your program exists in c:\foo\MyApp.exe and you run it from that directory.  If you called Path.GetFullPath() and passed in "..\..\..\..\..\bar.cs", what would you expect it to do?  My initial guess was that it would throw since that path goes above the root directory however it will just pretend it didn't and return c:\bar.cs. 

Comments (1)

  1. Oliver Slay says:

    Running ‘CD ……’ at the root C: prompt in a cmd window does not throw an error either…

    this is the same behaviour as you’d get in a cmd window:

    C:Programs>CD ……….Files


Skip to main content