vb.net "getting the base name of a file"

  • Thread starter Thread starter samadams_2006
  • Start date Start date
S

samadams_2006

Hello,

Suppose in VB.NET I have a file at:

c:\bitmaps\image1.bmp

and I want to get the "basename" (ie: image1)
and the "path" (ie: c:\bitmaps\)

How do I go about it? It doesn't appear that io.file has these
features?

Thanks.
 
If you're using VB2005:

Console.Writeline(Path.GetDirectoryName("C:\bitmaps\image1.bmp"))

will give you "C:\Bitmaps"

Path also has GetFileName (image1.bmp), GetExtension (bmp),
GetFileNameWithoutExtension (image), GetPathRoot (C:\) ....

Robin S.
 
Back
Top