473,386 Members | 1,773 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,386 software developers and data experts.

FileName

Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or whatever)
through a dummy customer page (customer.html) using a text box on this page.

I am getting the problem that my code is taking the entire path as file name
instead of that only name of attachment file name e.g. it should take only
attachment file name.
Dim file_coll As HttpFileCollection
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEnumerator

Do While en_file_coll.MoveNext

postedfile = file_coll.Item(i)

If postedfile.FileName.Length 64 Then

Throw New local_exception("Filename too long " & postedfile.FileName)
Exit Do
End If
This postedfile.FileName is coming as “C:\Documents and
Settings\wfmadmin\Desktop\testAttachmentFiles\att3 .txt" instead of att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+919886735837
kr**********@hotmail.com

Jun 27 '08 #1
3 1678
It is designed like this. FileInfo class provides a bunch of properties for
various parts of file name. With them you can easily take the parts you
want.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"deepak" <de****@discussions.microsoft.comwrote in message
news:4A**********************************@microsof t.com...
Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or
whatever)
through a dummy customer page (customer.html) using a text box on this
page.

I am getting the problem that my code is taking the entire path as file
name
instead of that only name of attachment file name e.g. it should take only
attachment file name.
Dim file_coll As HttpFileCollection
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEnumerator

Do While en_file_coll.MoveNext

postedfile = file_coll.Item(i)

If postedfile.FileName.Length 64 Then

Throw New local_exception("Filename too long " &
postedfile.FileName)
Exit Do
End If
This postedfile.FileName is coming as "C:\Documents and
Settings\wfmadmin\Desktop\testAttachmentFiles\att3 .txt" instead of
att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any
folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+919886735837
kr**********@hotmail.com

Jun 27 '08 #2
hi,

i had a problem as to find file extension and i have solved that by this C#
code; may give you an opinion...

string resimDosyaUzantisi =
resim1FU.FileName.Substring(resim1FU.FileName.Last IndexOf(".") + 1, 3);

"deepak" <de****@discussions.microsoft.com>, iletisinde şunu yazdı,
news:4A**********************************@microsof t.com...
Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or
whatever)
through a dummy customer page (customer.html) using a text box on this
page.

I am getting the problem that my code is taking the entire path as file
name
instead of that only name of attachment file name e.g. it should take only
attachment file name.
Dim file_coll As HttpFileCollection
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEnumerator

Do While en_file_coll.MoveNext

postedfile = file_coll.Item(i)

If postedfile.FileName.Length 64 Then

Throw New local_exception("Filename too long " &
postedfile.FileName)
Exit Do
End If
This postedfile.FileName is coming as “C:\Documents and
Settings\wfmadmin\Desktop\testAttachmentFiles\att3 .txt" instead of
att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any
folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+919886735837
kr**********@hotmail.com
Jun 27 '08 #3

"Tahir" <ku*********@gmail.comwrote in message
news:84**********************************@microsof t.com...
hi,

i had a problem as to find file extension and i have solved that by this
C# code; may give you an opinion...

string resimDosyaUzantisi =
resim1FU.FileName.Substring(resim1FU.FileName.Last IndexOf(".") + 1, 3);

"deepak" <de****@discussions.microsoft.com>, iletisinde şunu yazdı,
news:4A**********************************@microsof t.com...
>Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or
whatever)
through a dummy customer page (customer.html) using a text box on this
page.

I am getting the problem that my code is taking the entire path as file
name
instead of that only name of attachment file name e.g. it should take
only
attachment file name.
Dim file_coll As HttpFileCollection
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEnumerator

Do While en_file_coll.MoveNext

postedfile = file_coll.Item(i)

If postedfile.FileName.Length 64 Then

Throw New local_exception("Filename too long " &
postedfile.FileName)
Exit Do
End If
This postedfile.FileName is coming as “C:\Documents and
Settings\wfmadmin\Desktop\testAttachmentFiles\att 3.txt" instead of
att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any
folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+919886735837
kr**********@hotmail.com
Look at System.IO.Path. There are all the functions (no rewriting
required) to get file names, extensions etc.

LS

Jun 27 '08 #4

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

Similar topics

3
by: S.W. Rasmussen | last post by:
With the risk of being accused of multi-posting I would like to draw the attention to a serious visual basic/windows issue discussed in the microsoft.public.vb.bugs newsgroup. As pointed out below...
11
by: hokiegal99 | last post by:
How would I determine if a filename is greater than a certain number of characters and then truncate it to that number? For example a file named XXXXXXXXX.txt would become XXXXXX fname = files...
4
by: Michael | last post by:
All, I'll asked a question but I was not detailed (clear) enough for people to help so I'll retry. I have a cgi script pass a variable from one page to the next. The 'receiving' page replaces...
10
by: Brian Gruber | last post by:
Hi, I'm looking for a way to rename a whole directory of files in short order. The files in the directory have different lengths, however all of them end with _xxxx the x's represent a randomly...
8
by: Lad | last post by:
Hello, what is a way to get the the extension of a filename from the path? E.g., on my XP windows the path can be C:\Pictures\MyDocs\test.txt and I would like to get the the extension of the...
12
by: IamIan | last post by:
I searched the archives but couldn't find anyone else with this problem. Basically I'm grabbing all ASCII files in a directory and doing geoprocessing on them. I need to calculate a z-factor based...
4
by: B Squared | last post by:
I'm trying to pass a filename (which is a jpeg image) to a php function / file so that it will display. I know that its simple to get PHP to display an image hardcoding in the filename. For...
10
by: Steve | last post by:
I am trying to create a downloader which will bypass the saveas box in the WebBrowser control. I have the file downloading, but I don't know what the filename is that is being passed through the...
0
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL...
12
by: vj | last post by:
I am using Borland C++. I run a program which generates output data files, say 'Voltage.dat', 'Current.dat'. I have a variable in my code (say N), and for various values of N (for each value of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.