Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FileName

0 views
Skip to first unread message

deepak

unread,
May 7, 2008, 3:27:01 AM5/7/08
to
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_dee...@hotmail.com

Eliyahu Goldin

unread,
May 7, 2008, 3:41:37 AM5/7/08
to
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" <dee...@discussions.microsoft.com> wrote in message
news:4AB17B59-3408-4E00...@microsoft.com...

Tahir

unread,
May 7, 2008, 12:34:36 PM5/7/08
to
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);

"deepak" <dee...@discussions.microsoft.com>, iletisinde şunu yazdı,
news:4AB17B59-3408-4E00...@microsoft.com...

Lloyd Sheen

unread,
May 7, 2008, 1:48:21 PM5/7/08
to

"Tahir" <kurkc...@gmail.com> wrote in message
news:8452A177-8A5E-4FBA...@microsoft.com...

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

LS

0 new messages