我正在尝试制作一个程序,无论它在哪里安装都无关紧要。
以下是我在路径前面使用的代码。
Dim TilesPad As String
Dim Grass2Path As String
Dim Character As Char = Chr(34)
TilesPad = System.IO.Path.GetFullPath("Foto's")
Grass2Path = TilesPad & "\Grass2.png"
Dim Tile00 As Image = Image.FromFile(Character & Grass2Path & Character)
Dim ghx As Graphics
ghx = Me.CreateGraphics
ghx.DrawImage(Tile00, 0, 0, 100, 100)
错误代码:mscorlib.dll中出现未处理的“System.ArgumentException”类型异常
这是我不在路径前使用的代码。
Dim TilesPad As String
Dim Grass2Path As String
TilesPad = System.IO.Path.GetFullPath("Foto's")
Grass2Path = TilesPad & "\Grass2.png"
Dim Tile00 As Image = Image.FromFile(Grass2Path)
Dim ghx As Graphics
ghx = Me.CreateGraphics
ghx.DrawImage(Tile00, 0, 0, 100, 100)
错误代码:System.Drawing.dll中出现未处理的“System.IO.FileNotFoundException”类型异常
其他信息:C:\ Users \ Gebruiker \ Documents \ Game Project \ GameProjectVB \ GameProject2 \ bin \ Debug \ Foto's \ Grass2.png
注意:System.IO.Path.Combine会忽略TilesPad,这就是我不使用它的原因
注意2:如果我在Image.FromFile()中复制路径,那么它可以正常工作