473,466 Members | 1,366 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3182
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MK | last post by:
What would be the best platform-independent way to refer to the current (execute) path for a Python script? self.dirname = ??? This variable should contain directory name for the current path....
31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
4
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+....
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
5
by: Paul | last post by:
Hi, Using the code below I can extract the filename from a path but I would like to know how to get just the path too. So if the full path is "C:\A Long Time Ago\In A Galaxy\Far Far...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
2
by: Alphonse Giambrone | last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and have so far found it to be excellent. Downloaded all the code from Apress and working in chapter 4, I get the error shown...
3
by: SteveB | last post by:
I have posted this question in the Visual Basic 2005 and Visual Basic .Net 2005 discussion groups, also. Hi. I am developing an application/web page with VB.Net that will populate a SQL...
5
by: Steve | last post by:
Hi all Does anybody please know a way to extract an Image from a pdf file and save it as a TIFF? I have used a scanner to scan documents which are then placed on a server, but I need to...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.