[RESOLVED] Downloading a .txt loses it's formatting
Hi all,
I have a .txt file stored on a server, not it's pretty well formatted with paragraphs, spacing, tabs, and even bullet points. When accessed directly with the browser, it displays fine. However, using Inet's GET method:
Code:
TextIn = WebInet.OpenURL("http://URLHERE/DIR/Assign.txt")
Open "C:\Assign.txt" For Output As #FF
Write #FF, TextIn
Close #FF
DFU
Shell "notepad.exe C:\Assign.txt", vbNormalFocus
Or the "DownloadFromURL" method:
Code:
Private Sub DownLoadFromURL(ByVal url As String, ByVal filename As String)
'
' Download a file from a given URL
'
Dim bytes() As Byte
Dim fnum As Integer
Dim ftext As String
'
' Download the file and load into byte array
'
ftext = url & filename
bytes() = WebInet.OpenURL(ftext, icByteArray)
fnum = FreeFile
'
' Write the downloaded file to disk
'
Open "C:\" & filename For Binary Access Write As #fnum
Put #fnum, , bytes()
Close #fnum
End Sub
DownLoadFromURL "http://URL/DIR", "Assign.txt"
Just download the text file as one huge block of text, unformatted, with wierd characters where the bullets / tabs should be. How can I download the file and retain it's original formatting? I can use this GET method to download a .doc of the same file, and it stays completely in tact
Fair enough ^_^
Can anyone explain how to download it via FTP though, differentl to what I've already done? I used an FTP command, with an FTP Inet.. I can't remember the exact one, but I know it needed my domain, username, and pass.. I think it didn't return the file at all
I think that there is a problem with the file, which involves the format on the server. It is probably not a Windows server, and there isn't a VbCrLf isn't.
Post some of the file, so we can see it.
You can also try the Internet Control. Here is an example:
The server is my free hosting for my cable connection, NTL. We get like, 20 megs of free space, so yeah, it's probably Linux or something. I would use my own server, but my FTP server has stopped working properly recently.. My dyndns has too, maybe it just needs a format.
Anyhow, here's a link to the file itself: Link
It's my college assignment. I just made it into a .txt from a doc and uploaded it to test the system (I need to do this for another program, too).
Here's a link to the file AFTER it had been downloaded: Link
I tried loading it on a new form as well, reading the file in one line as a time and adding it to the textbox, with a breakline inbetween each line. It just gave me a horribly contorted version of the file with odd sets of words on one line, like between 2 and 6 words per line
EDIT:
I just realised, that when I'd uploaded the horibly screwed up file back onto my server, it viewed fine again in a text browser! I then put the second file on my own server instead, and again, it looks file!
Here's a screenshot of what it looks like to me, accessed locally:
Did you save it as a textfile in Word or Wordpad, or did you try to copy/paste it into notepad? Fx opened the first one fine, and the second one with a few spacing errors. Nothing like the image though. Did you upload it as a text file, or a binary?
I originally wrote the file in Word, and copied the text into Notepad and saves it as a .txt, where originally (stored locally) the layout and formatting appeared file. I didn't actually upload it with VB at all, I uploaded it with my FTP program. I'm not sure what kind of uploading that uses though...
I originally wrote the file in Word, and copied the text into Notepad and saves it as a .txt, where originally (stored locally) the layout and formatting appeared file. I didn't actually upload it with VB at all, I uploaded it with my FTP program. I'm not sure what kind of uploading that uses though...
I think it is not a problem because of uploading and downloading or other server issue. I got the same issue as depicted in the picture (notepad) when I opened the same in Notepad.
When I opened the same in Word there is no issue. And I also tried with some other text editors and i got no issue.
I think its because of word formatting like tab etc. As you said you typed the data in ms word and you copied it into notepad and you saved the file. but some sort of formatting retains in that file. So, you are getting these issues.