FileName

D

deepak

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
(e-mail address removed)
 
T

Tahir

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.LastIndexOf(".") + 1, 3);
 
L

Lloyd Sheen

Tahir said:
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.LastIndexOf(".") + 1, 3);

Look at System.IO.Path. There are all the functions (no rewriting
required) to get file names, extensions etc.

LS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top