我得到一个未处理的类型'System.InvalidCastException'的异常

时间:2015-04-23 01:31:44

标签: vb.net

每次使用此代码时,我都会收到InvalidCastException。有人可以帮忙吗?我正在开发一个名为Crystal的程序。 Crystal是您所有游戏的库。

 Label1.Text = "Please wait..."
    'This will get the game's info so it can use it for REASONS.
    Label1.Text = "Getting game info..."
    Dim fileReader As String
    fileReader = My.Computer.FileSystem.ReadAllText(gamepath \ "crystal\gamename.txt")    '<-------- Error Here

    'This will check the contents, just to make sure that it is correct.
    Label1.Text = "Now checking contents..."
    If My.Computer.FileSystem.DirectoryExists(gamepath \ "crystal") Then
        Label1.Text = "Yup. This is a Crystal game."
    Else
        MsgBox("This is NOT a crystal game. Make sure the crystal folder is in the package. ")
        Me.Close()
    End If
    'Crystal Folder Files

    'This will check for the gamename.txt
    Label1.Text = "Checking crystal folder data..."
    If My.Computer.FileSystem.FileExists(gamepath \ "crystal\gamename.txt") Then
        Label1.Text = "Found gamename.txt"
    End If
    'This will check for the image.png
    If My.Computer.FileSystem.FileExists(gamepath \ "crystal\image.png") Then
        Label1.Text = "Found image.png"
    End If

    'This will check for start.bat
    If My.Computer.FileSystem.FileExists(gamepath \ "crystal\start.bat") Then
        Label1.Text = "Found start.bat"
    End If
    ' This will create the folder the game is going to be in.

    ' This will extract the game to C:\Crystal\library
    Label1.Text = "Extracting Game files..."
    ZipFile.ExtractToDirectory(gamepath, "C:\Crystal\library")

0 个答案:

没有答案