473,386 Members | 1,812 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,386 software developers and data experts.

VB.NET Checking for remote file

Hi there,

First-time poster but long-time lurker.

I've been working on an application in VB.NET which will serve as a web-installer on a client machine, looking locally for files on a list downloaded from the server, checking their versions against server versions, and downloading updates where necessary, via HTTP or FTP. It's all going remarkably well so far and I've found VB very easy to pick up.

Where I've had trouble is in a function to check whether or not a file exists on the repository; essentially, that is, to check whether http://domain.com/path/to/file.ext is valid. I've found various different ways of checking for files on a local machine, and several for checking on local-network servers (I believe - all of the paths were \\server\path\to\file.ext or similar).

Finally, I'd be averse to (but not entirely against) bundling up a C# dll or similar. If that's the only way, then I'd still really appreciate a helping hand with the code, but if there's any chance of doing this in VB (even if it is more complex), I'd much rather be able to make the whole thing into one standalone executable.

Thanks very much in advance

John
Feb 2 '08 #1
1 2278
Well, after some more searching, I've found a way to do this; rather obvious and I'm surprised I didn't think of it before.

Essentially, the code creates a web request for the file:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click() Handles Button1.Click
  2.   Dim request As HttpWebRequest = CType(WebRequest.Create(http://domain.com/path/to/file.xtn), HttpWebRequest)
  3.   Try
  4.     Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
  5.     MessageBox.Show("File Found") ' will only be processed if request successful
  6.   Catch ex As WebException
  7.     If ex.Status <> WebExceptionStatus.Success Then
  8.       MessageBox.Show("Errors")
  9.     End If
  10.   End Try
  11. End Sub
For anyone who wants to use this code, I suggest altering the processing of ex.Status to take account of the various different WebExceptionStatus values, which can be found here: http://technet.microsoft.com/en-us/l...ionstatus.aspx. This will allow you to supply more specific error messages based on the actual error encountered; for me, the above is all I need.

Hope someone else finds this useful too!


Yours

John
Feb 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil Lamey | last post by:
Hi Folks, I have run into a bit of an issue with checking for files. Some files reside on Server X and some on Server Y. The page with all the links is on Server X. If the file exists we...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
1
by: POnfri | last post by:
Hi, I have a problem in a peace of code were i'm doing a file copy using File.Copy. The Source is local and the target is a remote machine. Example: File.Copy(C:\temp\hi.txt,...
1
by: gryffin | last post by:
im trying to do file extension checking but its not working :( i have the following in the head <script language="JavaScript"> extArray = new Array(".jpg", ".png", ".bmp"); function...
5
by: Victor | last post by:
Hi everybody, could anybody explain the following phenomen : I have this line in my project : include "http://".$domain."/help/".$language."/".$defaultIndex."/".$help.".php"; This...
3
by: David | last post by:
Hi, Is there a general way of placing an 'error_check' include file into my website, and put the include line onto all 'asp' pages. In the event that any error occurs on any asp page or with the...
2
by: Simon.Whiteside | last post by:
If someone has created a database for me and transferred it over is there any way that I can check I have full access to all areas? I am a beginner with Access and so the development has been...
5
by: idorjee | last post by:
hi guys, I'm trying to figure how to read a file from my other computer, and here is what i did. it doesn't work for some reason. i would really appreciate if you could help me with this. i get...
4
by: Noy B | last post by:
Hi, I have developed a small application that is using a MSAccess DB. the problem is that it was developed on a machine where the application and the DB are both located. now it needs to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.