just wondering if possible

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,

i'm using method webclient.filedownload to automatically download a file
from an internet site. that works great. well i was wondering if there was a
way to monitor or check if that file has changed since the last time it was
downloaded?

thanks,
rodchar
 
Rodchar

Of course you can, here I made a sample how you can do it with the most
showed link in this newsgroup.

\\\
Public Class MVPS
Public Shared Sub Main()
Dim conlength As String
Dim wbRq As Net.HttpWebRequest = _
DirectCast(Net.WebRequest.Create _
("http://dotnet.mvps.org/index.html"), _
Net.HttpWebRequest)
wbRq.Timeout = 2000
Try
Dim wbRs As Net.HttpWebResponse = _
DirectCast(wbRq.GetResponse(), _
Net.HttpWebResponse)
Dim wbHCol As Net.WebHeaderCollection = _
wbRs.Headers
For i As Integer = 0 To wbHCol.Count - 1
Dim header As String = wbHCol.GetKey(i)
Dim values As String() = _
wbHCol.GetValues(header)
If values.Length > 0 Then
Console.Write(header)
Console.Write(" ")
Console.Write(values(0))
Console.Write(vbCrLf)
End If
Next
wbRs.Close()
Catch
Console.Write("could not get something")
End Try
End Sub
End Class
///

I hope this helps?

Cor
 
hey Cor,

your code snippet is very new to me. could you explain in psuedocode what
it's doing.

i auto download this file each week. And each week the source file on the
internet is just replaced with new data but the same file name, so the file
is always there and never deleted. so you're saying this code snippet will
handle this?

sorry that i couldn't get right away. forgive me please.

rodchar
 
Rodchar,

Just try it, the only thing you have to do is paste it in a project class
and run.
When you use a class you have to set in the project properties the startup
to sub main.

You see than information from the file (and about the used server) in your
output window..

I hope this helps?

Cor
 
cool. so now would i put this in a timer to check occasionally and compare?

or could i use something like a FileSysemWatcher or an event that as soon as
the source file is update my program should run?
 
Rodchar,

I think that I would use the timer.

I was thinking of a service however that has no sense because you need it
when your program run, so you can start with it as first action in your
program.

I hope this helps,

Cor
 
is it ok if i want the timer to check once a day
timer.interval = 86400000
would there be anything wrong with this?
 
Rodchar,

With this your program would go all day.

What is the goal, to know if that page is changed.
Or
Take action in your program when that page is changed.

In the first I would think first of setting a start in the microsoft
scheduler.
(You can do it in a service as a lot do, however I find that a little bit
weird it does nothing, so your user can delete that as well).

In the second option I would as I wrote just look if it is changed at the
start of the program.

Cor
 
Actually the goal is both.

i have to check if the file has changed and if it hasn't to keep checking.
And if it has to download and process the file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top