I have been struggling a bit trying to get this to work. I am trying to rename the file but can't seem to get it to work. The file creates but just doesn't seem to rename with the text in the text box. Any ideas to point me in the right direction would be great. Below is the code.
Code to generate File Code:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click If File.Exists("c:\Sample.txt") Then 'shows message if testFile exist MsgBox("File Already Exist ") Else 'create the file testFile.txt File.Create("c:\Sample.txt") MsgBox("File Has Been Created ") End If End Sub
Code to Rename File Code:
Public Sub RenameFile() Dim mOldFilePath As String = "C:\Sample.txt" 'Dim mExtension As String Dim mNewFileName As String mNewFileName = txtName.Text My.Computer.FileSystem.RenameFile(mOldFilePath, mNewFileName)
Thanks in Advance
RCA20


Reply With Quote
