Dragging URLs, Checking URLs

Audax321

Regular
Joined
May 4, 2002
Messages
90
Hello,

I have three questions listed below that I would appreciate answered. Here are the questions:

1. Is there a way to point a URL to the OpenFileDialog control, because it downloads and points the path to the one located in the temporary internet files folder, without displaying the actual dialog box? That way the user could drag/enter a URL and the program would use the OpenFileDialog control to download the file if it exists without user intervention and point it to the temporary internet files location. This would be easier than downloading the file yourself, because this method should also work for local files.

2. Is there a way to check if a file actually exists on a http/ftp server. For example, if the user enters a URL such as http://www.files.com/text.txt, the program can tell if the file text.txt exists on the server or not. A method that works for local and internet files is preferred.

3. How do I drag and drop a hyperlink from Internet Explorer to a textbox in my application. This worked fine in VB6 using text dragging, but doesn't seem to work in .NET.

Thanks for any help :)
 
You don't need the OpenFileDialog to download things off the net; you can use the WebClient class to do it. For example,
Visual Basic:
Dim wc As New WebClient()
Dim strData As String, bytData As Byte()

bytData = wc.DownloadData("http://www.xtremedotnettalk.com")
strData = System.Text.ASCIIEncoding.ASCII.GetString(bytData)

MessageBox.Show(strData)
That would show the HTML to the front page of DotNetForums in a MessageBox. It would work with any file, though. You could also use the DownloadFile method to put it on the computer, rather than in a string var.

The WebClient with throw a System.Net.WebException if something is wrong (i.e. the file is not on the server), so if you catch that, you know it couldn't download the data.
 
Thanks, but is there a way to just check if a file exists on a server without attempting to download it?
 
Anybody have any idea how to accept dragged hyperlinks from internet explorer??? I can't figure it out...
 
Back
Top