Dim Msg As String = ""
Dim AppPath As String = My.Application.Info.DirectoryPath
Msg = "AppPath=" & AppPath & vbCrLf & vbCrLf
Dim NewPath1 As String = IO.Path.Combine(AppPath, "\text\test.txt")
Msg &= "IO.Path.Combine(AppPath, ""\text\test.txt"")" & vbCrLf & " 得到的是" & vbCrLf & NewPath1 & vbCrLf
Dim NewPath2 As String = IO.Path.Combine(AppPath, "/text\test.txt")
Msg &= "IO.Path.Combine(AppPath, ""/text\test.txt"")" & vbCrLf & " 得到的是" & vbCrLf & NewPath2 & vbCrLf
Dim NewPath3 As String = IO.Path.Combine(AppPath, "text\test.txt")
Msg &= "IO.Path.Combine(AppPath, ""text\test.txt"")" & vbCrLf & " 得到的是" & vbCrLf & NewPath3 & vbCrLf & vbCrLf
Msg &= "也就是说" & vbCrLf & " System.IO.Path.Combine(String, String) As String" & vbCrLf & " 的第二个参数不能以""/""或""\""开头"
MsgBox(Msg)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Msg As String = ""
Dim AppPath As String = My.Application.Info.DirectoryPath & "\"
Msg = "AppPath=" & AppPath & vbCrLf & vbCrLf
Dim NewPath1 As String = IO.Path.Combine(AppPath, "\text\test.txt")
Msg &= "IO.Path.Combine(AppPath, ""\text\test.txt"")" & vbCrLf & " 得到的是" & vbCrLf & NewPath1 & vbCrLf
Dim NewPath2 As String = IO.Path.Combine(AppPath, "/text\test.txt")
Msg &= "IO.Path.Combine(AppPath, ""/text\test.txt"")" & vbCrLf & " 得到的是" & vbCrLf & NewPath2 & vbCrLf
Dim NewPath3 As String = IO.Path.Combine(AppPath, "text\test.txt")
Msg &= "IO.Path.Combine(AppPath, ""text\test.txt"")" & vbCrLf & " 得到的是" & vbCrLf & NewPath3 & vbCrLf & vbCrLf
Msg &= "也就是说" & vbCrLf & " System.IO.Path.Combine(String, String) As String" & vbCrLf & " 的第一个参数可以""/""或""\""结尾头"
MsgBox(Msg)
End Sub
[本日志由 tiancao1001 于 2022-03-19 01:32 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |