473,287 Members | 1,947 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,287 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 3512
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.