Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 :)

  • *Experts*
Posted

You don't need the OpenFileDialog to download things off the net; you can use the WebClient class to do it. For example,

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...