How To Get The FileName ?

C

Cor Ligthert

Hi Tiraman,

Somewhere bellow you find a discussion about this, however the answers are
dim filename as string = Path.GetFileName("c:\temp\test\test.txt")
or in the same context
Path.GetFileNameWithoutExtension

I hope this helps?

Cor
 
T

Tiraman

Hi ,

I m using the HttpPostedFile.FileName Function in order to get the file name

but i m getting the fully-qualified name which is not good for me .

how can i get only the file name without the path .

For Instance ,

if i m sending the file "C:\MyFiles\Test.txt"

then the result will be "Test.txt"


Best Regards ,

Tiraman :)
 
H

Herfried K. Wagner [MVP]

* "Tiraman said:
how can i get only the file name without the path .

For Instance ,

if i m sending the file "C:\MyFiles\Test.txt"

\\\
Imports System.IO
..
..
..
Dim FileName As String = Path.GetFileName("C:\MyFiles\Test.txt")
///
 
T

Tiraman

BTW
i m not look for a way to get the short file name by doing some code like
this

Dim iPos as Integer
Dim iPosSave as Integer
Dim sPath as string = "c:\temp\test\test.txt"

iPos = 1

Do
iPos = InStr(iPos, sPath, "\")
If iPos = 0 Then Exit Do
Else
iPos = iPos + 1
iPosSave = iPos - 1
End If
Loop
response.write(Trim(Mid(sPath, iPosSave + 1)))


i m looking for some method in VB.NET which doing this already .

10x
 

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

Top