Results 1 to 4 of 4

Thread: help with System.Net

  1. #1

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    help with System.Net

    Code:
            Dim key As Microsoft.Win32.RegistryKey
            key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
            Dim Proxy As String = CType(key.GetValue("ProxyServer"), String)
            Dim Enable As String = CType(key.GetValue("ProxyEnable"), String)
            If Enable = 1 Then
    
                'Gets Time
                Dim StartTime As Decimal
                StartTime = TimeOfDay.Minute & "." & TimeOfDay.Second
                Dim wc As New System.Net.WebClient()
                Dim wp As New System.Net.WebProxy(Proxy)
                wc.DownloadFile("http://www.online-solutions.org/flash/player/flashplayer7_netscape.exe", _
                         "C:\flashplayer7_netscape.exe")
    
                'Gets time
                Dim EndTime As Decimal
                EndTime = TimeOfDay.Minute & "." & TimeOfDay.Second
    
                ''Deletes the file
                'filesys.DeleteFile("c:\newf1.zip")
    
                Dim TimeIt As Integer
                If EndTime - StartTime = 0 Then
                    MessageBox.Show("Error")
                    End
                Else
                    'Calculates the download rate and stores it in a variable
                    TimeIt = 668 / (EndTime - StartTime)
                End If
            End If
    This is the code that I have I need to be able to put the proxy that is detected into the download string. I left out the Else statement because it doesnt matter but if someone can help I would be greatful.

    Thanks
    "A candle loses nothing by lighting another candle."

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: help with System.Net

    What is the problem?

  3. #3

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Re: help with System.Net

    I need to set the proxy so that the file will download. I have already got the proxy setings and put it in proxy variable.
    "A candle loses nothing by lighting another candle."

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: help with System.Net

    Try this code, I didn't actually have a proxy server set up to test, but I was able to still download it when it didn't find a proxy server...
    VB Code:
    1. Dim key As Microsoft.Win32.RegistryKey
    2.         key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
    3.         Dim Proxy As String = CType(key.GetValue("ProxyServer"), String)
    4.         Dim Enable As String = CType(key.GetValue("ProxyEnable"), String)
    5.         MsgBox(Enable)
    6.         Dim wc As New System.Net.WebClient
    7.         Dim wp As New System.Net.WebProxy(Proxy)
    8.         wc.DownloadFile((wp.GetProxy(New System.Uri( _
    9.                  "http://www.online-solutions.org/flash/player/flashplayer7_netscape.exe")).ToString), _
    10.                  "C:\flashplayer7_netscape.exe")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width