我正在努力解决如何在封闭引号中使用已定义的字符串(例如“(”))。我有两个文本框,一个用于IP或共享名称,另一个用于驱动器号。当我按下我的按钮时,我希望它映射驱动器。以下是我的代码。
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim drivePath As String = TextBox1.Text
Dim driveLetter As String = TextBox2.Text
Process.Start("cmd", "/k net use driveLetter drivePath")
End Sub
我正在努力如何在
的参数中使用我的driveLetter和drivePath字符串Process.Start("cmd", "/k .....")
任何帮助都会受到赞赏,因为我需要做很多这样的事情。
答案 0 :(得分:2)
为此目的使用字符串的Format方法:
Process.Start("cmd", String.Format("/k net use {0} {1}", driveLetter, drivePath))
答案 1 :(得分:1)
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim drivePath As String = TextBox1.Text
Dim driveLetter As String = TextBox2.Text
Process.Start("cmd", "/k net use " & driveLetter & " " & drivePath)
End Sub