我无法下载以下代码:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    DownloadFile("http://mirror.switch.ch/ftp/mirror/videolan/vlc/2.0.3/vlc-2.0.3.tar.xz", "C:\TEST\vlc-2.0.3.tar.xz")
End Sub

Public Sub DownloadFile(ByVal _URL As String, ByVal _SaveAs As String)
        Dim _WebClient As New System.Net.WebClient()
        _WebClient.DownloadFile(_URL, _SaveAs)
End Sub
.

将弹出以下错误:(从德语翻译为英语):

从Microsoft错误弹出:

==>在system.dll中出现“system.net.webexception”类型的未处理的exeption。

和调试器:

==> exeption:触发:“指定了无效参数”(System.net.sockets.socketException)System.Net.Sockets.SocketException已被触发。“已指定无效参数”

完整代码:

Imports System
Imports System.Net

Public Class Form2
    Dim str_hd As String

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        For Each drive As System.IO.DriveInfo In My.Computer.FileSystem.Drives
            Dim dbl_capacity As Double
            Dim dbl_free As Double
            Dim dbl_used As Double

            If drive.IsReady Then
                dbl_capacity = drive.TotalSize / 1073741824
                dbl_free = drive.TotalFreeSpace / 1073741824
                dbl_used = dbl_capacity - dbl_free

                dbl_capacity = Fix(dbl_capacity * 1) / 1
                dbl_free = Fix(dbl_free * 10) / 10
                dbl_used = Fix(dbl_used * 10) / 10


                str_hd = str_hd & "Laufwerk " & drive.Name & "  -  " _
                        & drive.VolumeLabel & vbCrLf _
                        & "Benutzt: " & dbl_used & " GB" & " / " & dbl_capacity & " GB" & vbCrLf & "Frei: " _
                        & dbl_free & "GB" & vbCrLf & "-------------------------------" & vbCrLf
            End If
        Next

        txtbox_hd.Text = str_hd

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        DownloadFile("http://www.aerztekammer-hamburg.de/berufsrecht/Berufsordnung.pdf", "C:\TEST\Berufsordnung.pdf")
    End Sub



    Public Sub DownloadFile(ByVal _URL As String, ByVal _SaveAs As String)
            Dim _WebClient As New System.Net.WebClient()
            _WebClient.DownloadFile(_URL, _SaveAs)
    End Sub

End Class
.

有帮助吗?

解决方案

文件夹生成函数icetagcode是否存在?此外,来自文档:

在中间层应用程序中使用此方法,例如ASP.NET页面,如果应用程序执行的帐户无权访问该文件的帐户,则会收到错误。

Wenn Sie Diese Methode in Einer Anwendung der中泪Verwenden,z。B. Einer Asp.Net-Seite,Erhalten Sie Eine Fehlermellung,Wenn Das Konto,Unter Dem Die AnwendungAusgeführtWird,NichtÜberdie Berechtigung Zugriff Auf DeatiVerfügt。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top