문제

다음 코드가있는 파일을 다운로드 할 수 없습니다.

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.net.webexception"유형에서 처리되지 않은 이점이 System.dll에 나타납니다.

및 디버거에서 : 여기에 이미지 설명

==> exeption : triggered : "잘못된 인수가 지정되었습니다."(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
.

도움이 되었습니까?

해결책

폴더 C:\TEST가 존재합니까?또한 문서에서 :

ASP.NET 페이지와 같이 중간 계층 응용 프로그램 에서이 방법을 사용하는 경우 응용 프로그램에 실행할 계정에 파일에 액세스 할 수있는 권한이없는 경우 오류가 발생합니다.

WENN SIE DIESE Meterode in Middle-Tear Verwenden, Z.B. Einer Asp.net-Seite, Erhalten Sie Eine Fehlermeldung, Wenn Das Konto, Unter Def Antweng Ausgeführt Wird, Nicht Über Die BerechTigung Zum Zugriff Auf Die Daii Verfügt.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top