所以我有一个包含大量文本框的表单(txtUsername,txtPassword,txtAddress .......)
和im保存到.txt文件后,根据txtUsername调用该文件 所以,C:\ Example \ Example \ Example \" txtUsername" .txt
Public Class Form1
Private Sub save_Click(sender As Object, e As EventArgs) Handles save.Click
If System.IO.File.Exists("\ ..\ ..\Resources\Users\<txtUsername>.txt")
) Then
MsgBox("File Already Exists)")
Else
Dim objWriter As New System.IO.StreamWriter("\ ..\ ..\Resources\Users\<txtUsername>.txt"
objWriter.Write(txtsave.Text)
objWriter.Close()
End If
End Sub
End Class
答案 0 :(得分:0)
解决
创建了一个名为path的变量然后使用
System.IO.StreamWriter(path)
其中path = "\ ..\ ..\Resources\Users\" + txtUsername.Text + ".txt"