Newbie String Q

  • Thread starter Thread starter Mike W
  • Start date Start date
M

Mike W

I have :a friend: who needs to extract a filename from a variable
path_filename.
The path/filename combo is stored in a string and is different each time.

Something like

strFile = txtPathFile.text 'were the txtPathFile textbox is populated with
c:\windows\win.com

what is the most straight forward way to pull win.com out and place into
another string like strFile?

I really appreciate...I mean, my friend really appreciates the help. ;-)

Thanks,
m
 
Something like:

dim fi as new fileinfo(path_filename)\
fname = fi.name
fextension = fi.extension
 
Mike W said:
I have :a friend: who needs to extract a filename from a variable
path_filename.
The path/filename combo is stored in a string and is different each time.

Something like

strFile = txtPathFile.text 'were the txtPathFile textbox is populated
with c:\windows\win.com

what is the most straight forward way to pull win.com out and place into
another string like strFile?


\\\
Imports System.IO
..
..
..
Dim FileName As String = Path.GetFileName(Me.TextBoxPathFile.Text)
///
 
Mike said:
I have :a friend: who needs to extract a filename from a variable
path_filename.
The path/filename combo is stored in a string and is different each time.

Something like

strFile = txtPathFile.text 'were the txtPathFile textbox is populated with
c:\windows\win.com

what is the most straight forward way to pull win.com out and place into
another string like strFile?

I really appreciate...I mean, my friend really appreciates the help. ;-)

Thanks,
m

use indexof and substring

Dim BackSlash as Integer= FullPath.LastIndexOf("\")
FileName = FullPath.Substring((BackSlash + 1), FullPath.Length -
(BackSlash + 1))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top