Home All Groups Group Topic Archive Search About

Splitting filenames into parts

Author
17 Mar 2006 4:32 PM
Dave Cullen
The OpenFileDialog returns a full pathspec and file name in its Filename
property. I want to display only the file and extension without the
path. Is there a .NET function to extract that part of the string?

Thanks

Author
17 Mar 2006 4:39 PM
Al Reid
"Dave Cullen" <nospam@mail.com> wrote in message news:441AE48F.31F6CF2B@mail.com...
> The OpenFileDialog returns a full pathspec and file name in its Filename
> property. I want to display only the file and extension without the
> path. Is there a .NET function to extract that part of the string?
>
> Thanks

io.Path.GetFileName(path)



--

Al Reid
Author
17 Mar 2006 5:05 PM
zacks
Dave Cullen wrote:
> The OpenFileDialog returns a full pathspec and file name in its Filename
> property. I want to display only the file and extension without the
> path. Is there a .NET function to extract that part of the string?
>
> Thanks

If you need to get anything other than filename, check out the FileInfo
Class.
Author
17 Mar 2006 8:53 PM
VHD50
Suppose the filefullpath returned by the OpenFileDialog is stored in
strMyFile, then you can use FileInfo class to get all sort of information you
want.
Dim fInfo = New FileInfo(strMyFile)
Dim fName As String = fInfo.Name
Dim fExt As String = fInfo.Extension
Dim size As Long = fInfo.Length
bla...
bla...
bla....
Hope this answers your question.
VHD50.

Show quoteHide quote
"za***@construction-imaging.com" wrote:

>
> Dave Cullen wrote:
> > The OpenFileDialog returns a full pathspec and file name in its Filename
> > property. I want to display only the file and extension without the
> > path. Is there a .NET function to extract that part of the string?
> >
> > Thanks
>
> If you need to get anything other than filename, check out the FileInfo
> Class.
>
>
Author
18 Mar 2006 12:59 PM
Herfried K. Wagner [MVP]
"Dave Cullen" <nospam@mail.com> schrieb:
> The OpenFileDialog returns a full pathspec and file name in its Filename
> property. I want to display only the file and extension without the
> path. Is there a .NET function to extract that part of the string?

You may want to take a look at the shared methods of the 'System.IO.Path'
class.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>