Hello,
When it's needed to upload a file, and get the name of it:
uploadfile is a HtmlInputFile type:
string NameOfFile = uploadfile.Post edFile.FileName ;
NameOfFile will not only get the name of the file, but the complete path on
which it was on the client ("C:\somefolder \test.exe"). How to get just the
file name (test.exe), without path information?
I know, I could just cut the string, search for the appearance of "/" or "\"
cut the rest etc. but, isn't there a more elegant way? 6 1210
The path class: http://msdn.microsoft.com/library/de...classtopic.asp
provides serveral helpful function such as Path.GetFileNam e (which will get
you the filename that you wanted)
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"the friendly display name" wrote: Hello,
When it's needed to upload a file, and get the name of it:
uploadfile is a HtmlInputFile type:
string NameOfFile = uploadfile.Post edFile.FileName ;
NameOfFile will not only get the name of the file, but the complete path on which it was on the client ("C:\somefolder \test.exe"). How to get just the file name (test.exe), without path information?
I know, I could just cut the string, search for the appearance of "/" or "\" cut the rest etc. but, isn't there a more elegant way?
System.IO.Path. GetFileName()
"the friendly display name"
<th************ ********@discus sions.microsoft .com> wrote in message
news:B2******** *************** ***********@mic rosoft.com...
Hello,
When it's needed to upload a file, and get the name of it:
uploadfile is a HtmlInputFile type:
string NameOfFile = uploadfile.Post edFile.FileName ;
NameOfFile will not only get the name of the file, but the complete path on
which it was on the client ("C:\somefolder \test.exe"). How to get just the
file name (test.exe), without path information?
I know, I could just cut the string, search for the appearance of "/" or "\"
cut the rest etc. but, isn't there a more elegant way?
This brings up an interesting issue. What is the path when other platforms
such as Mac or Unix upload a file to the server? Each platform has their
own way of representing paths and will the Path class be able to take this
into account?
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:45******** *************** ***********@mic rosoft.com... The path class: http://msdn.microsoft.com/library/de...classtopic.asp provides serveral helpful function such as Path.GetFileNam e (which will get you the filename that you wanted) -- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"the friendly display name" wrote:
Hello,
When it's needed to upload a file, and get the name of it:
uploadfile is a HtmlInputFile type:
string NameOfFile = uploadfile.Post edFile.FileName ;
NameOfFile will not only get the name of the file, but the complete path on which it was on the client ("C:\somefolder \test.exe"). How to get just the file name (test.exe), without path information?
I know, I could just cut the string, search for the appearance of "/" or "\" cut the rest etc. but, isn't there a more elegant way?
Hi Peter,
The MSDN documentation lists only Windows products under the "Platforms" for
this class. So I do not really know how it will work when receiving files
from the Unix or Mac. I have not tried it myself.
If any one has Unix or Mac, wants to try it and let us know the result, then
they can try this page from my website: http://www.webswapp.com/demos/PathClass.aspx which will display back the
outcome; whether the Path method catches an exception or manages to get the
filenames correctly.
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Peter Rilling" wrote: This brings up an interesting issue. What is the path when other platforms such as Mac or Unix upload a file to the server? Each platform has their own way of representing paths and will the Path class be able to take this into account?
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message news:45******** *************** ***********@mic rosoft.com... The path class: http://msdn.microsoft.com/library/de...classtopic.asp provides serveral helpful function such as Path.GetFileNam e (which will get you the filename that you wanted) -- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"the friendly display name" wrote:
Hello,
When it's needed to upload a file, and get the name of it:
uploadfile is a HtmlInputFile type:
string NameOfFile = uploadfile.Post edFile.FileName ;
NameOfFile will not only get the name of the file, but the complete path on which it was on the client ("C:\somefolder \test.exe"). How to get just the file name (test.exe), without path information?
I know, I could just cut the string, search for the appearance of "/" or "\" cut the rest etc. but, isn't there a more elegant way?
Tried it from Linux, it works.
Btw. the description from the MSDN page says it already, that it is
cross-plattform:
"Performs operations on String instances that contain file or directory path
information. These operations are performed in a cross-platform manner."
"Phillip Williams" wrote: Hi Peter,
The MSDN documentation lists only Windows products under the "Platforms" for this class. So I do not really know how it will work when receiving files from the Unix or Mac. I have not tried it myself.
If any one has Unix or Mac, wants to try it and let us know the result, then they can try this page from my website: http://www.webswapp.com/demos/PathClass.aspx which will display back the outcome; whether the Path method catches an exception or manages to get the filenames correctly.
-- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Peter Rilling" wrote:
This brings up an interesting issue. What is the path when other platforms such as Mac or Unix upload a file to the server? Each platform has their own way of representing paths and will the Path class be able to take this into account?
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message news:45******** *************** ***********@mic rosoft.com... The path class: http://msdn.microsoft.com/library/de...classtopic.asp provides serveral helpful function such as Path.GetFileNam e (which will get you the filename that you wanted) -- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"the friendly display name" wrote:
> Hello, > > When it's needed to upload a file, and get the name of it: > > uploadfile is a HtmlInputFile type: > > string NameOfFile = uploadfile.Post edFile.FileName ; > > NameOfFile will not only get the name of the file, but the complete path > on > which it was on the client ("C:\somefolder \test.exe"). How to get just > the > file name (test.exe), without path information? > > I know, I could just cut the string, search for the appearance of "/" or > "\" > cut the rest etc. but, isn't there a more elegant way?
Didn't mean that the Path class would be invoked on a Mac computer, but if
you are running a website on Windows, and a Mac client (using something like
the Safari browser) visits your webpage and uploads a file using the file
upload tag, then the path received by the server would probably be the path
would probably be Mac formatted.
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:5E******** *************** ***********@mic rosoft.com... Hi Peter,
The MSDN documentation lists only Windows products under the "Platforms" for this class. So I do not really know how it will work when receiving files from the Unix or Mac. I have not tried it myself.
If any one has Unix or Mac, wants to try it and let us know the result, then they can try this page from my website: http://www.webswapp.com/demos/PathClass.aspx which will display back the outcome; whether the Path method catches an exception or manages to get the filenames correctly.
-- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Peter Rilling" wrote:
This brings up an interesting issue. What is the path when other platforms such as Mac or Unix upload a file to the server? Each platform has their own way of representing paths and will the Path class be able to take this into account?
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message news:45******** *************** ***********@mic rosoft.com... > The path class: > http://msdn.microsoft.com/library/de...classtopic.asp > provides serveral helpful function such as Path.GetFileNam e (which will > get > you the filename that you wanted) > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "the friendly display name" wrote: > >> Hello, >> >> When it's needed to upload a file, and get the name of it: >> >> uploadfile is a HtmlInputFile type: >> >> string NameOfFile = uploadfile.Post edFile.FileName ; >> >> NameOfFile will not only get the name of the file, but the complete >> path >> on >> which it was on the client ("C:\somefolder \test.exe"). How to get just >> the >> file name (test.exe), without path information? >> >> I know, I could just cut the string, search for the appearance of "/" >> or >> "\" >> cut the rest etc. but, isn't there a more elegant way? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: john |
last post by:
Hi
Here's what I want:
After uploading the file, I would like to preview the filename and the
original path uploaded from the client side and not what is now
uploaded to the server..
for example, C:\mydocuments\myfiles\myfile.doc
How can I do this?
|
by: Braky Wacky |
last post by:
Hello,
I have an ASP.NET webpage that uses an instance of
System.Web.UI.HtmlControls.HtmlInputFile for uploading files to our
server. I came across the documentation at MSDN for upping the
filesize limit, once I saw the behavior of the page bombing with files
bigger than 4 MB. So far so good.
But the situation I'm coming across is that...
|
by: Jameel |
last post by:
I am facing 2 problems:
1. I have files uploaded to the server and have the relevant information in
database, and now I want to pull the image name and path from database and
have the images dynamically loaded into DataList, but I am not able to
display images in DataList , can u help me please to sort out the problem ,
OR it would be...
|
by: riteshjain82 |
last post by:
Hi, Please go through this:
I am having a file (default.asp) on which i am taking many details from
a user before mailing it to someone. I have also provided the user with
a facility of uploading files on a server. I am uploading files from a
page upload.asp which has a link on default.asp. Now my problem is
that, how can i send the file...
|
by: sathyashrayan |
last post by:
Dear Group,
Please look at the following demo link.
http://www.itsravi.com/demo/new_pms/admin/addproject.php
| |
by: suryadithya |
last post by:
Hi,
I am very new to php. And I have got to submit a project very soon (By tomorrow evening). So please help.
The problem is this. I have created a file upload mechanism where the uploaded files are stored under a different id for security something like 0001.pdf, 0002.jpg etc.. The original names are stored in a mysql database. Now I have a...
|
by: Muddasir |
last post by:
Hi All.
Anyone plz tell me how can I upload a file with the file name of my choice.
am having problem with this, the file got uploaded but not with the name I wanted to...how can I do this ....please tell me.
Here is the code:
<html>
<head>
|
by: Tony M |
last post by:
vs 2005 - vb - web page - xp pro
I'm trying to use the fileupload control.
I assume I need to add a user name and password, but can't figure out how.
Dim UpLoadPath As String
UpLoadPath = Server.MapPath("\Blah\") 'I've tried several different
variations of this
|
by: liberty1 |
last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help.
PROBLEM NUMBER 1:
Using PHP and MySQL, I am able to upload picture successfully unto the server but not so with the file name of the picture even though other parameters in my form got inserted successfuly in the...
|
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...
|
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...
| |
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. ...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
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
| |
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...
| |