0
If My.Computer.FileSystem.FileExists("pack/locale_ro.epk") Then My.Computer.FileSystem.DeleteFile("pack/locale_ro.epk")

    PB_GSM.Value = 10

    If My.Computer.FileSystem.FileExists("pack/locale_ro.eix") Then My.Computer.FileSystem.DeleteFile("pack/locale_ro.eix")

    PB_GSM.Value = 20

    If My.Computer.FileSystem.FileExists("pack/root.epk") Then My.Computer.FileSystem.DeleteFile("pack/root.epk")

    PB_GSM.Value = 30

    If My.Computer.FileSystem.FileExists("pack/root.eix") Then My.Computer.FileSystem.DeleteFile("pack/root.eix")

    PB_GSM.Value = 40

    My.Computer.Network.DownloadFile("http://example")

I believe i wrote everything correct, but it doesn't matter how i write the "if"-s , i can not end them. if i wrote End if next to a line it says something like "End if must be preceded by a matching if". And another problem , the line about the download link is underlined and it says"Overload resolution failed because no accessible 'DownloadFile' accepts this number of arguments".

P.S: this is a try for a metin2 patcher, i do not know exactly how to do it but i'm sure this is a way to update the game only at the files that i neeed.Thanks for help:)

2 Answers2

3

You have them all in one line. Don't put anything after the "Then" keyword.

If My.Computer.FileSystem.FileExists("pack/locale_ro.epk") Then
  My.Computer.FileSystem.DeleteFile("pack/locale_ro.epk")
  PB_GSM.Value = 10
End If

If looking for an else-if situation, this would be the syntax:

If My.Computer.FileSystem.FileExists("pack/locale_ro.epk") Then
  My.Computer.FileSystem.DeleteFile("pack/locale_ro.epk")
  PB_GSM.Value = 10
ElseIf My.Computer.FileSystem.FileExists("pack/locale_ro.eix") Then
  My.Computer.FileSystem.DeleteFile("pack/locale_ro.eix")
  PB_GSM.Value = 20
' etc, etc
End If

Note though that this will only run the code on the first "True" line found.

For the DownloadFile, you also need to specify the destination:

My.Computer.Network.DownloadFile("http://example", "c:\temp\myfile.txt")

Substitute the c:\temp\ path with the one you are using.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • @JohnBustos I added it, but I don't think it's 100% clear from the code that `If...ElseIf` is being requested. The OP could be wanting to delete all those files. The PB_GSM.Value sure makes it seem though that you're right. – LarsTech Jan 04 '13 at 18:37
2

When you post the Then statement followed by an expression that closes that If statement. You have, in essence, already closed all your If statements.

aphoria
  • 19,796
  • 7
  • 64
  • 73
kencordero
  • 151
  • 1
  • 5