469,282 Members | 1,977 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Generic way to extract filename from path independent on platform

Hello!

I'm using the following method to retrieve the filname from a full server
path:

<%
sub getfname(strPath)
Dim fName
fName = Mid(strPath,InStrRev(strPath,"\")+1)
'fName = strPath
Response.Write( fName )
end sub
%>

However this only works on Windows systems as it checks for backslash. Is
there a more generic way to do this, or should I check for both backslash
and slash in the path?

thanks,

Peter
Jul 22 '05 #1
3 3087
huh? What else would it be if not a \
--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"PeterB" <pe***@data.se> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello!

I'm using the following method to retrieve the filname from a full server
path:

<%
sub getfname(strPath)
Dim fName
fName = Mid(strPath,InStrRev(strPath,"\")+1)
'fName = strPath
Response.Write( fName )
end sub
%>

However this only works on Windows systems as it checks for backslash. Is
there a more generic way to do this, or should I check for both backslash
and slash in the path?

thanks,

Peter

Jul 22 '05 #2
A / perhaps? Unix notatio, there are Unix/Linux modules for .NET out there
so it would be possible to run an ASP site on a linux-machine...

/ Peter
"Curt_C [MVP]" <software_AT_darkfalz.com> skrev i meddelandet
news:uW**************@TK2MSFTNGP09.phx.gbl...
huh? What else would it be if not a \
--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"PeterB" <pe***@data.se> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello!

I'm using the following method to retrieve the filname from a full server
path:

<%
sub getfname(strPath)
Dim fName
fName = Mid(strPath,InStrRev(strPath,"\")+1)
'fName = strPath
Response.Write( fName )
end sub
%>

However this only works on Windows systems as it checks for backslash. Is
there a more generic way to do this, or should I check for both backslash
and slash in the path?

thanks,

Peter


Jul 22 '05 #3
no, not directly.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"PeterB" <pe***@data.se> wrote in message
news:eE**************@TK2MSFTNGP10.phx.gbl...
A / perhaps? Unix notatio, there are Unix/Linux modules for .NET out there
so it would be possible to run an ASP site on a linux-machine...

/ Peter
"Curt_C [MVP]" <software_AT_darkfalz.com> skrev i meddelandet
news:uW**************@TK2MSFTNGP09.phx.gbl...
huh? What else would it be if not a \
--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"PeterB" <pe***@data.se> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello!

I'm using the following method to retrieve the filname from a full
server path:

<%
sub getfname(strPath)
Dim fName
fName = Mid(strPath,InStrRev(strPath,"\")+1)
'fName = strPath
Response.Write( fName )
end sub
%>

However this only works on Windows systems as it checks for backslash.
Is there a more generic way to do this, or should I check for both
backslash and slash in the path?

thanks,

Peter



Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

31 posts views Thread by John Roth | last post: by
4 posts views Thread by Michael Kennedy [UB] | last post: by
70 posts views Thread by Michael Hoffman | last post: by
5 posts views Thread by Paul | last post: by
2 posts views Thread by Rob Cowie | last post: by
2 posts views Thread by Alphonse Giambrone | last post: by
3 posts views Thread by SteveB | last post: by
5 posts views Thread by Steve | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.