我用下面的代碼擺弄周圍。不過,我需要從C:\MY FOLDER\MY FILE
格式的C:\\MY FOLDER\\MY FILE
格式重組的文件名。我怎樣才能做到這一點?更改C:文件夾文件到C:\ \文件夾文件
Public Class Form1
Private Sub TextBox1_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Click
'OpenFileDialog1.Title = "Please Select a File"
'OpenFileDialog1.InitialDirectory = "C:temp"
OpenFileDialog1.ShowDialog()
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
Dim strm As System.IO.Stream
strm = OpenFileDialog1.OpenFile()
TextBox1.Text = OpenFileDialog1.FileName.ToString()
If Not (strm Is Nothing) Then
''insert code to read the file data
strm.Close()
'MessageBox.Show("file closed")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FILEx As String = "C:\FILEPATH.txt"
If System.IO.File.Exists(FILEx) = True Then
Dim objWriter As New System.IO.StreamWriter(FILEx, False)
objWriter.WriteLine(TextBox1.Text)
objWriter.Close()
End If
End Sub
End Class
`code`
代碼很粗糙,我只是測試了一些東西。
這是什麼的問題有代碼爲什麼你加倍\」做什麼? S'你到底想幹什麼? – dbasnett 2011-03-02 12:41:51