473,594 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ 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(strPat h)
Dim fName
fName = Mid(strPath,InS trRev(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 3189
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.s e> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hello!

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

<%
sub getfname(strPat h)
Dim fName
fName = Mid(strPath,InS trRev(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_da rkfalz.com> skrev i meddelandet
news:uW******** ******@TK2MSFTN GP09.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.s e> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hello!

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

<%
sub getfname(strPat h)
Dim fName
fName = Mid(strPath,InS trRev(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.s e> wrote in message
news:eE******** ******@TK2MSFTN GP10.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_da rkfalz.com> skrev i meddelandet
news:uW******** ******@TK2MSFTN GP09.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.s e> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hello!

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

<%
sub getfname(strPat h)
Dim fName
fName = Mid(strPath,InS trRev(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
3117
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. It should work on every platform (Linux, Windows...). I'm not interested in parsing this string. That is, simple f.write(self.dirname)
31
3897
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 in the os module got objectified properly (or at least with some semblance of OO propriety!) In the issues section:
4
48200
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+. System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
70
4061
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 Python standard library, and Reinhold Birkenfeld started a discussion on it in python-dev <http://mail.python.org/pipermail/python-dev/2005-June/054438.html>. The upshot of the discussion was that many python-dev'ers wanted path added to the...
5
12474
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 Away\SomeFilename.txt" The filename is: SomeFilename.txt The path only is: C:\A Long Time Ago\In A Galaxy\Far Far Away\ I know there's other methods of getting the filename only, path only etc.
2
23371
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 using '/' as delimiters and get the last 'word'. The reason I'm not entirely happy with that method is that it is platform specific. I would prefer to use a built in method if possible. Cheers,
2
22288
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 below. I am running IIS5 on WinXP Pro. Server Error in '/Chapter04' Application. ---------------------------------------------------------------------------- ---- A generic error occurred in GDI+. Description: An unhandled exception occurred...
3
10575
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 database from text extracted from PDF documents. However, I am having a difficult time finding or developing the appropriate code to convert the PDF streams into text strings. Has anyone developed code to convert PDF's to Text? I was able write a...
5
5749
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 extract the image of the document (just the first page if there are multiple pages) and save it as a TIFF so I can then use the Tesseract OCR to get the text in the image.
0
7954
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
7882
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8377
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8244
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5415
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3905
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2391
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 we have to send another system
0
1218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.