473,418 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

WebClient.DownloadFile - Missing Carriage Returns & Line Feeds

I am having a problem with the download of web pages via the
WebClient.DownloadFile function in the specialized VB.Net 2003 I.E.
plug-in I am designing to speed up the work on my latest project.

When I edit the web pages in notepad I see a square wherever I normally
see a carriage return and a line feed when viewing the source in I.E.

How can I make the web pages come down readable so I can easily make my
two manual deletions (different text in each file)?

The code located in modMain.bas (app has no forms) is as follows:

Sub SaveFile
'define variables
Dim clsWebClient As WebClient = New WebClient
Dim intFileNameStart As Integer
Dim intFilePathStart As Integer
Dim strFileName As String
Dim strLocalFilePath As String
Dim strRemoteFilePath As String

'intialize variables
strRemoteFilePath = System.Environment.GetCommandLineArgs(1).ToString
intFileNameStart = (InStrRev(strRemoteFilePath, "/") + 1)
strFileName = Mid$(strRemoteFilePath, intFileNameStart)

strLocalFilePath = Left$(strRemoteFilePath, (intFileNameStart - 2))
intFilePathStart = (InStrRev(strLocalFilePath, "/") + 1)
strLocalFilePath = Mid$(strLocalFilePath, intFilePathStart)

'download and store file
clsWebClient.DownloadFile(strRemoteFilePath, _
conCfgInfo.strDefaultParentPath & _
strLocalFilePath & "\" & strFileName)

'clean up
clsWebClient.Dispose()

End Sub

conCfgInfo.strDefaultParentPath which contains "D:\Pictures\Big Dig\" is
read from Save File.cfg via another sub. The first command line
argument is set by VBS code in Save File.htm when I select the right
click menu Save File... choice in I.E. to the URL of what I right
clicked on. strLocalFilePath is set to the last subdirectory in the
remote path.

So if strRemoteFilePath contains
http://web.archive.org/web/200210090...100/img001.htm
img001.htm gets downloaded to D:\Pictures\Bigdig\f073100\img001.htm in
my local file system.
Nov 21 '05 #1
2 3219
Lila,

That page should be readable for you. However it can be that it is in
another code style than that you use. Than you have at least to encode it
using the encoding class.

Unicode
http://www.geocities.com/Athens/Acad.../fontset.htm#b

OS systems
http://www.microsoft.com/globaldev/r...ocversion.mspx

Encoding class
http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #2
I just found the problem. After numerous revisions to try and get the
web page to be saved in an encoding different from the Western European
(Windows Encoding) used by explorer with Auto-Select checked that would
let notepad render the source properly I noticed that the MS-DOS Editor
and type command would render the page properly.

Opening the page in the MS-DOS Editor and using the Save command on the
File menu would enable me to see the page correctly in notepad, but with
the source code of the page you get redirected to from
http://www.bigdig.com/thtml/f073100/img001.htm not the source code for
http://web.archive.org/web/200210090...100/img001.htm.

After that I replaced the

clsWebClient.DownloadFile(strRemoteFilePath, _
conCfgInfo.strDefaultParentPath & _
strLocalFilePath & "\" & strFileName)

code with

WriteWebPage(GetWebPage(strRemoteFilePath),
conCfgInfo.strDefaultParentPath & _
strLocalFilePath & "\" & strFileName)

where the new GetWebPage function returns a string with the source of a
passed in web page and the new WriteWebPage sub writes a passed in web
page source to a passed in file name. I placed

strNewData = Replace(strWebPage, vbLf, vbCrLf)
'eliminates the display of squares in notepad

in the WriteWebPage sub just before the PrintLine command.

As soon as I rebuilt the program and ran it again I got a readable web
page source (still for the wrong web page).

A quick check revealed improper VBS code in Save File.htm.

It originally had:

if external.menuArguments.event.srcElement.tagName = "IMG" then
userURL = external.menuArguments.event.srcElement.href
else
userurl = external.menuArguments.event.srcElement.parent.hre f
end if

because I could not use
userURL = external.menuArguments.event.srcElement.href for .htm files
with out getting a script error.

When I replaced the second occurrence of
userurl = external.menuArguments.event.srcElement.parent.hre f with
userurl = external.menuArguments.document.URL I got the right web page
complete with carriage returns and line feeds.
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: pascal_dumont | last post by:
Hi all, I have a problem with downloading files by using WebClient wc = new WebClient(); wc.DownloadFile("http://some_url.com/some_file.gif", "some_file.gif"); This returns the error 403...
6
by: Laura D | last post by:
How can I identify a carriage return in C++? \r, \f, \0, \n, \t does not work. I have also tried !isprint(ch), iscntrl(ch), isspace(ch), etc....with no luck! I even poked around in the MSDN and...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
8
by: DEWright_CA | last post by:
Why does WebClient.DownloadFile loose my completed path? Ok, I have a function in my app then when my button is clicked it checks to see if the files come from a local drive or a http address....
1
by: peter.rietmann | last post by:
I have been suddenly having a performance problem downloading images from one server (productive) to another (productive) using the following code .. WebClient webClient = new WebClient(); try...
4
by: Morten Snedker | last post by:
I'm trying to download a file. I've tried both using webclient and the httpWebRequest. Either way it returns a "407 proxy authentication required". The program is to be run externally, so...
1
by: David Satz | last post by:
Hello--I just upgraded to Visual Studio .NET 2005 and suddenly, all my .NET 1.1 applications that accessed Web sites have broken. For example, this code: WebClient wc = new WebClient();...
1
by: vin.dor | last post by:
Dear All, I am using WebClient in my Visual Studio .Net 2003 project to download an image from the Internet. The following is my function: C# Code: public static bool downloadFile(string...
8
by: =?Utf-8?B?UnVpIE9saXZlaXJh?= | last post by:
WebClient.DownloadFile I am using the WebClient.DownloadFile function to download a file from server to a local client. When I execute the below code, file is created in server and not in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.