By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

How To Get The FileName ?

P: n/a
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 :-)
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
"Tiraman" <ti*****@netvision.net.il> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
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 :-)

Nov 20 '05 #2

P: n/a
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
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
"Tiraman" <ti*****@netvision.net.il> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
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 :-)


Nov 20 '05 #3

P: n/a
Hello Cor

This Is What i was looking for :-)

10x

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
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
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
"Tiraman" <ti*****@netvision.net.il> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
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 :-)



Nov 20 '05 #4

P: n/a
* "Tiraman" <ti*****@netvision.net.il> scripsit:
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")
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

P: n/a
10x :-)

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2h************@uni-berlin.de...
* "Tiraman" <ti*****@netvision.net.il> scripsit:
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")
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.