Reputation: 2237
I am attempting to download a simple .txt file from my server. The file contents is as follows:
.jpg
.txt
.js
.css
.png
.gif
.xml
.cgi
.ico
.php
/wp-content/
/comments/
wp-login
/feed/
wp-login.php?
/category/
/sample-page
?replytocom
/page/
/tag
/author/
/trackback/
comment-page"
Having the lines breaks as so is necessary for my prorgam.
When the file is downloaded from the server all line breaks are stripped for some reason and the content is shown in one single line like so:
.jpg.txt.js.css.png.gif.xml.cgi.ico.php/wp-content//comments/wp-login/feed/wplogin.php?/category//sample-page?replytocom/page//tag/author//trackback/comment-page
My code is quite simple:
Dim folderpath As String = Directory.GetCurrentDirectory + "/Blacklists/"
Dim folderpath2 As String = Directory.GetCurrentDirectory + "/Blacklists/UrlBlacklist.txt"
If (Not System.IO.Directory.Exists(folderpath)) Then
System.IO.Directory.CreateDirectory(folderpath)
End If
My.Computer.Network.DownloadFile("http://mywebsite.com/blacklists/UrlBlacklist.txt",folderpath2, False, 500)
What can I do differently to keep the line breaks?
Upvotes: 0
Views: 170
Reputation: 31394
I doubt any stripping is occurring. The file probably has Unix line endings (line feed only) while you are using an editor (Notepad I'd guess) that requires Windows/DOS line endings (carriage return line feed). You can try to load and convert the file manually:
Dim fileData as String = System.IO.File.ReadAllText(folderPath2)
fileData = fileData.Replace(vbLf, vbCrLf)
System.IO.File.WriteAllText(folderPath2, fileData)
Upvotes: 3