FileName

  • Thread starter Thread starter deepak
  • Start date Start date
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)
 
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);
 
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
 
Back
Top