[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

get image and byte size from internet in visual basic .net

We have a static image on our website and we use that to check if the site is up.  How could I get the image and byte size using visual basic .net with a url?
0
chadmanvb
Asked:
chadmanvb
  • 2
1 Solution
 
Luis PérezSoftware Architect in .NetCommented:
Try this:

'Download the image to a local path
My.Computer.Network.DownloadFile("http://...", "localPath")
'Get the image size
Dim fileSize As Int64 = New System.IO.FileInfo("localPath").Length

Open in new window


Hope that helps.
0
 
chadmanvbAuthor Commented:
Ohh, looks like that works.....one quick question.  How can I have it write over the image if it already exist in my local dir?
0
 
chadmanvbAuthor Commented:
Worked great.  Just used an overload so I could keep overwriting the file.

My.Computer.Network.DownloadFile _
    (address := "http://www.randomurl.com/randomfile.txt", _
    destinationFileName := Path.Combine(Environment.GetFolderPath( _
    Environment.SpecialFolder.ApplicationData), _
    "test/randomfile.txt"), _
    userName := string.Empty, password := string.Empty, _
    showUI := False, connectionTimeout := 100000, _
    overwrite := True)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now