Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Generic way to extract filename from path independent on platform

Reply
Thread Tools

Generic way to extract filename from path independent on platform

 
 
PeterB
Guest
Posts: n/a
 
      02-09-2005
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


 
Reply With Quote
 
 
 
 
PeterB
Guest
Posts: n/a
 
      02-10-2005
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:(E-Mail Removed)...
> huh? What else would it be if not a \
>
>
> --
> Curt Christianson
> Site & Scripts: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
> "PeterB" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Platform-independent way for storing application data Jan Thomä Java 15 02-19-2009 04:19 PM
Launching an independent Python program in a cross-platform way (including mac) =?iso-8859-1?B?QW5kcuk=?= Python 8 05-01-2007 11:47 AM
Extract filename from a filename typed by user =?Utf-8?B?Sm9l?= ASP .Net 1 08-23-2004 11:29 PM
Platform independent way to play an mp3 file Gandalf Python 1 08-18-2004 11:13 AM
Platform-independent way to refer to execute path MK Python 1 06-25-2003 05:43 PM



Advertisments