473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Request.FilePath gets full path...built in way to grab just the filename?

using Request.FilePath will return the entire file path:

directory/directory/myfile.aspx

Is there a built function in ASP.net to grab just the filename (myfile.aspx)
or do I need to write some string manipulation functions to grab it out of
the filepath?

-Darrel
May 16 '06 #1
3 3518
Use this function to strip out the filename:

System.IO.Path.GetFileName(sPath)

Here's more info:
http://windowssdk.msdn.microsoft.com...1_16219e3a.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Darrel" <no*****@nospam.com> wrote in message
news:Ol**************@TK2MSFTNGP03.phx.gbl...
using Request.FilePath will return the entire file path:

directory/directory/myfile.aspx

Is there a built function in ASP.net to grab just the filename
(myfile.aspx) or do I need to write some string manipulation functions to
grab it out of the filepath?

-Darrel

May 16 '06 #2
Here's a complete example using the script_name server variable for the path:

string pagename = System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]);

The pagename string variable will contain "myfile.aspx",
if that code is included in myfile.aspx's Page_Load event or any suitable page event.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uW**************@TK2MSFTNGP04.phx.gbl...
Use this function to strip out the filename:

System.IO.Path.GetFileName(sPath)

Here's more info:
http://windowssdk.msdn.microsoft.com...1_16219e3a.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Darrel" <no*****@nospam.com> wrote in message news:Ol**************@TK2MSFTNGP03.phx.gbl...
using Request.FilePath will return the entire file path:

directory/directory/myfile.aspx

Is there a built function in ASP.net to grab just the filename (myfile.aspx) or do I need to
write some string manipulation functions to grab it out of the filepath?

-Darrel


May 16 '06 #3
> Use this function to strip out the filename:

System.IO.Path.GetFileName(sPath)
I hope this helps


It does. Thanks!

-Darrel
May 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: mjakowlew | last post by:
Hi, I'm trying to use some string manipulation from a file's path. filepath='c:\documents\web\zope\file.ext' I need to extract everthing after the last '\' and save it. I've looked around...
6
by: Bruce Vander Werf | last post by:
Is there a method anywhere for extracting just the filename part of a full path name? --Bruce
6
by: Daniel Rimmelzwaan | last post by:
I want to send a biztalk document to an aspx page, and I need to see some sample code, because I just can't make it work. I have a port with transport type HTTP, pointing to my aspx page, something...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
0
by: darrel | last post by:
when I use 'request.filepage' I get the URL that is shown in the address bar of the browser. The catch is that it will not return the name of the page itself, it if isn't part of the URL (namly...
1
by: Smokey Grindle | last post by:
to start off with the page the free text box (version 3) is on has validateRequest="false" in the page directive already... but even with that when I am in the page and then click on a link to...
4
by: Dots | last post by:
I have a class library with a method called getpath(). I want to be able to get the full path of a folder and write some files to the (my_files_dir) folder. A console application will use this...
5
by: Smarty | last post by:
Dear Friends, I did a file type validation in Javascript. Just i want to check whether a selected file is BMP or JPG. I wrote the following function for it. function checkType(){ Text =...
3
by: Ramon F Herrera | last post by:
My application receives a filepath as an argument. Obviously, it can come in several formats, such as: filename.ext ..\filename.ext ...\..\filename.ext this\is_a\relative\path\finally.ext
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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,...
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...
0
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...

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.