std.path review: update

Jussi Jumppanen jussij at zeusedit.com
Thu Jul 21 00:36:37 PDT 2011


Lars T. Kyllingstad Wrote:

> On Wed, 20 Jul 2011 14:16:04 -0400, Steven Schveighoffer wrote:
>
> Any .NET programmers out there?  Can you please tell me what the 
> following functions return?
> 
>   System.IO.Path.GetDirectoryName("\\foo\bar")
>   System.IO.Path.GetPathRoot("\\foo\bar\baz")

This code:
  using System;
  
  namespace Test
  {
     static class Program
     {
        [STAThread]
        static void Main()
        {
           string test;
  
           test = @"\\foo\bar\";
           Console.WriteLine("System.IO.Path.GetDirectoryName(" + test + ")");
           Console.WriteLine(System.IO.Path.GetDirectoryName(test));
  
           test = @"\\foo\bar";
           Console.WriteLine("System.IO.Path.GetDirectoryName(" + test + ")");
           Console.WriteLine(System.IO.Path.GetDirectoryName(test));
  
           test = @"\\foo\bar\baz";
           Console.WriteLine("System.IO.Path.GetDirectoryName(" + test + ")");
           Console.WriteLine(System.IO.Path.GetPathRoot(test));
        }
     }
  }

produced this output:

  C:\temp>test.exe
  System.IO.Path.GetDirectoryName(\\foo\bar\)
  \\foo\bar
  System.IO.Path.GetDirectoryName(\\foo\bar)
  
  System.IO.Path.GetDirectoryName(\\foo\bar\baz)
  \\foo\bar

Cheers Jussi


More information about the Digitalmars-d mailing list