0

我正在努力解决如何在封闭引号中使用定义的字符串,例如(“”)。我有两个文本框,一个用于 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 .....")

任何帮助将不胜感激,因为我需要做很多此类事情。

4

2 回答 2

2

为此目的使用字符串的Format方法:

Process.Start("cmd", String.Format("/k net use {0} {1}", driveLetter, drivePath))
于 2013-10-02T15:10:01.677 回答
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
于 2013-10-02T15:16:13.893 回答