File downloading problem on long file names

  • Thread starter Thread starter prakash.kgm
  • Start date Start date
P

prakash.kgm

Dear Friends,

I am using the following code to initiate a download in the client
side.

--------------------------
Aspx Page Name : WebForm2.aspx

fileStream =
File.Open("e:\à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜçÇà+â¦éÉè+ê-ë+î+ï+-à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜ-data.txt",
IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)

ReDim bytDocument(fileStream.Length)
fileStream.Read(bytDocument, 0, fileStream.Length)
fileStream.Close()

Dim realName As String =
"à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜçÇà+â¦éÉè+ê-ë+î+ï+-à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜ-data.txt"
Dim myname As String = System.Web.HttpUtility.UrlEncode(realName)

' If I did not used UrlEncode IE changes the characters to unkown chars
:(


Response.AddHeader("content-disposition", "attachment; filename=" &
myname)
Response.AddHeader("Content-Length", bytDocument.Length.ToString())
Response.ContentType = "application/x-unknown"
'Response.ContentType = "application/zip"

Response.BinaryWrite(bytDocument)
Response.Flush()
Response.Close()
Response.End()
------------------------------------------------------------------------------------

My file name contains the characters other than english.

When I call the page from IE The "File Download" dialog apperas without
any problem. but the file name is changed to "WebForm2.html" :(.
But if the file name is "à+â¦éÉè+ê-ë+î+ï.txt" {Smaller than
the previous one} working without any problems The file download dialog
appers with the name "à+â¦éÉè+ê-ë+î+ï.txt".

I have not got any problems in firefox browser.

Is anything I am doing wrong?

Regards
Prakash
 
Hi parakash,

Your windows language settings?

Regards.
Dear Friends,

I am using the following code to initiate a download in the client
side.

--------------------------
Aspx Page Name : WebForm2.aspx

fileStream =
File.Open("e:\à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜçÇà+â¦éÉè+ê-ë+î+ï+-à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜ-data.txt",
IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)

ReDim bytDocument(fileStream.Length)
fileStream.Read(bytDocument, 0, fileStream.Length)
fileStream.Close()

Dim realName As String =
"à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜçÇà+â¦éÉè+ê-ë+î+ï+-à+â¦éÉè+ê-ë+î+ï+ôGùdûOüÜ-data.txt"
Dim myname As String = System.Web.HttpUtility.UrlEncode(realName)

' If I did not used UrlEncode IE changes the characters to unkown chars
:(


Response.AddHeader("content-disposition", "attachment; filename=" &
myname)
Response.AddHeader("Content-Length", bytDocument.Length.ToString())
Response.ContentType = "application/x-unknown"
'Response.ContentType = "application/zip"

Response.BinaryWrite(bytDocument)
Response.Flush()
Response.Close()
Response.End()
------------------------------------------------------------------------------------

My file name contains the characters other than english.

When I call the page from IE The "File Download" dialog apperas without
any problem. but the file name is changed to "WebForm2.html" :(.
But if the file name is "à+â¦éÉè+ê-ë+î+ï.txt" {Smaller than
the previous one} working without any problems The file download dialog
appers with the name "à+â¦éÉè+ê-ë+î+ï.txt".

I have not got any problems in firefox browser.

Is anything I am doing wrong?

Regards
Prakash
 
Hi Prakash,

There-in lies your problem. The download dialog uses the windows language
settings (as does the alert box in IE) and so your unicode file name is not
decoded.
Solution. Use asci characterset filenames or rename the file stream to the
uses language settings.

Regards.
 
Back
Top