Path.GetFullPath and ":"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to make sure that a filename is an "absolute path" (ie. has a drive
spec. and root, or else is a UNC path) if it isn't already one.
Path.GetFullPath seems to do the trick, except there is one thing in the MSDN
documentation that makes me nervous.

MSDN says that GetFullPath will throw NotSupportedException if its argument
contains a ":". If GetFullPath behaved this way I would not be able to use it
because, for example, Path.GetFullPath(@"D:\file.ext") would throw an
excpetion. Instead, I find that it does not throw an exception, but returns
"D:\file.ext" as I would like.

Does anyone know which behavior is correct? Is Path.GetFullPath supposed to
throw an exception if its argument contains a ":"? Or, is it that a ":" in
the pathname now supported in .NET 1.1 and the documentation is out of date?

Thanks in advance for any help,
Mark Urish
 
I wasn't able to find the part of MSDN that states that GetFullPath will
throw a NotSupportedException if the argument contains a ":"
After creating a quick test program, I confirmed that GetFullPath returns
the full path just as expected even when the input is already a full path.
 
Interesting. Well, given the test I ran yesterday, I would assume that it
means if the path contains a ":" after the first "\", which would be a bad
path, but again, in testing yesterday, using a full path returned a full
path without throwing any exceptions.
 
Back
Top