Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I have a tabbed application, when a user opens a file to be displayed in a tab I naturally want the filename to appear in the tab.

 

Using this:

 

openFileDialog1.get_FileName()

 

Puts the whole path in the tab, making the tab very long e.g.

 

C:/path/to/file.txt

 

I just want:

 

file.txt

 

To be in the tab. How do I go about doing that?

 

Thanks.

Posted
Hi,

 

I have a tabbed application, when a user opens a file to be displayed in a tab I naturally want the filename to appear in the tab.

 

Using this:

 

openFileDialog1.get_FileName()

 

Puts the whole path in the tab, making the tab very long e.g.

 

C:/path/to/file.txt

 

I just want:

 

file.txt

 

To be in the tab. How do I go about doing that?

 

Thanks.

 


dim stringBuffer() as String
stringBuffer = split("C:/path/to/file.txt", "/")

fileName = stringBuffer(ubound(stringBuffer))

Posted

dim path as string = "C:/path/to/file.txt"
System.IO.Path.GetFileName(path)

This way it will work regardless of whether the path uses "\"'s or "/"'s.

Anybody looking for a graduate programmer (Midlands, England)?
Posted

Old way...

 

Hi:

 

I to try to use the GetFileName methods like the other posters suggested...however, I sometimes do the following:

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim Path As String

Dim Pos As Integer

 

Path = "C:\FilePath\ReallyLong\LotsofDirectories\Practice\ScratchPad\bin\testing.bmp"

Pos = Path.LastIndexOf("\")

Path = Path.Substring(Pos + 1, Path.Length - (Pos + 1))

 

'return file name

MsgBox(Path)

 

End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...