Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / January 2008



Tip: Looking for answers? Try searching our database.

Wrong text file formatting when saved from stream

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AllisonJ - 29 Jan 2008 12:31 GMT
I you all! Thanks for reading!!!
I'm trying to download a text file through the download dialog box using Ado stream:

 set adoStream = Server.CreateObject("ADODB.Stream")
 adoStream.Open()
 adoStream.CharSet = "x-ansi"
 adoStream.Type = 2 ' adTypeText
 adoStream.WriteText( file_body )
 adoStream.Position = 0
 adoStream.Type = 1 'adTypeBinary

 Response.Clear
 Response.AddHeader "Content-Length", len(file_body)
 Response.AddHeader "Content-Transfer-Encoding", "binary"
 Response.AddHeader "Content-Disposition", "attachment; filename="& file_name &"; "
 Response.ContentType = "application/unknown"
 Response.BinaryWrite( adoStream.Read() )
 adoStream.Close
 Response.End

This is the look of the original string, with carriage returns and line feeds properly displayed

But when I open the downloaded file, it looks like this:

How can I recover the original formating of the file_body string in the saved file
Also I tried to use the ReadText method, but it puts a space between each character (???)

How can I solve this
Any clues highly appreciated
Allison J
Ralph - 29 Jan 2008 13:15 GMT
Find out what the little blocks are. My guess is they are line-feeds, or LF/CR, instead of CR/LF. Replace them.

-ralph

 I you all! Thanks for reading!!!
 I'm trying to download a text file through the download dialog box using Ado stream:

   set adoStream = Server.CreateObject("ADODB.Stream")
   adoStream.Open()
   adoStream.CharSet = "x-ansi"
   adoStream.Type = 2 ' adTypeText
   adoStream.WriteText( file_body )
   adoStream.Position = 0
   adoStream.Type = 1 'adTypeBinary

   Response.Clear
   Response.AddHeader "Content-Length", len(file_body)
   Response.AddHeader "Content-Transfer-Encoding", "binary"
   Response.AddHeader "Content-Disposition", "attachment; filename="& file_name &"; "
   Response.ContentType = "application/unknown"
   Response.BinaryWrite( adoStream.Read() )
   adoStream.Close
   Response.End

 This is the look of the original string, with carriage returns and line feeds properly displayed

 But when I open the downloaded file, it looks like this:

 How can I recover the original formating of the file_body string in the saved file
 Also I tried to use the ReadText method, but it puts a space between each character (???)

 How can I solve this
 Any clues highly appreciated
 Allison J
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.