У меня проблемы с следующим кодом.
Public Async Function update_launcher() As Task
Dim jsonGetter As JsonGetter = New JsonGetter()
Dim jArray As JArray = jsonGetter.get_array_from_api("http://www.example.com/json.php")
Dim count As Integer = jArray.Count
Dim num As Integer = 0
For Each current As JToken In jArray
num += 1
Me._mainWindow.UpdateAvancementLabel(String.Concat(New Object()() {"Updating file ", num, " of ", count}))
If Me.GetMD5HashFromFile(current("filename").ToString()) <> current("hash").ToString() AndAlso (current("platform").ToString() = "windows" OrElse current("platform").ToString() = "all") Then
Dim webClient As WebClient = New WebClient()
AddHandler webClient.DownloadFileCompleted, AddressOf Me.Completed
AddHandler webClient.DownloadProgressChanged, AddressOf Me.ProgressChanged
Dim uriString As String = "http://www.example.com/download/" + current("downloadpath")
Await webClient.DownloadFileTaskAsync(New Uri(uriString), current("filename").ToString())
End If
Next
End Function
Ошибки, которые я получаю из этого куска кода, в основном связаны с Me._mainWindow
линия и Dim uriString As String
линия.
Это должно считывать файл json.php, который выглядит следующим образом:
[
{
"filename":"update/Launcher.exe",
"downloadpath":"update/Launcher.exe",
"hash":" ",
"platform":"windows"},
{
"filename":"update/Launcher",
"downloadpath":"update/Launcher",
"hash":" ",
"platform":"linux"},
{
"filename":"update/Launcher",
"downloadpath":"update/Launcher",
"hash":" ",
"platform":"darwin"}
]
"hash"
это просто хеш MD5.
Если вам нужно больше деталей, дайте мне знать.
**Line 8:**
Value of type 'String' cannot be converted to '1-dimensional array of Object'.
Value of type 'String' cannot be converted to '1-dimensional array of Object'.
Value of type 'Integer' cannot be converted to '1-dimensional array of Object'.
Value of type 'Integer' cannot be converted to '1-dimensional array of Object'.
**Line 13:**
Operator '+' is not defined for types 'String' and 'Newtonsoft.Json.LingJToken'.
Задача ещё не решена.
Других решений пока нет …