私はどこでも検索しましたが、効果はありませんでした。VB.netを使用してファイルをダウンロードすると、不完全です
私は、ファイルダウンロードするには、このコードを使用してい:
Imports System.IO
Imports System.Security.AccessControl
Imports System.Net
Imports System.ComponentModel
Public Class Step4
Function GetUserName() As String
If TypeOf My.User.CurrentPrincipal Is
System.Security.Principal.WindowsPrincipal Then
' The application is using Windows authentication.
' The name format is DOMAIN\USERNAME.
Dim parts() As String = Split(My.User.Name, "\")
Dim username As String = parts(1)
Return username
Else
' The application is using custom authentication.
Return My.User.Name
End If
End Function
Private Sub Step4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Code of Step3
Dim URL As String = "http://skinsserver.exampleserver.com/skins.zip"
Dim filename As String = "C:\Users\" + GetUserName() + "\AppData\Roaming\Applicationsettings\skins.zip"
Using wc As New WebClient
wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)")
wc.DownloadFile(URL, filename)
End Using
End Sub
End Class
を私はすべてを試みたが、それは22キロバイトである一方で、ファイルの唯一の800バイトがダウンロードされています。
ブラウザからのダウンロードは問題ありません。
助けてください!
ありがとうございます!
実際のURLを投稿して試すことができますか? – Youssef13
同じファイルを別のサーバーにアップロードしましたが、このコードは正常に動作しました。しかし、これは私が使用しなければならないサーバです。それを修正する方法はありますか? – MatrixCow08
ブラウザでも質問コードのリンクが機能していません。 – Youssef13