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:
  1. Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
  2.  
  3.         If File.Exists("c:\Sample.txt") Then
  4.             'shows message if testFile exist
  5.             MsgBox("File Already Exist ")
  6.         Else
  7.             'create the file testFile.txt
  8.             File.Create("c:\Sample.txt")
  9.             MsgBox("File Has Been Created ")
  10.         End If
  11.     End Sub

Code to Rename File Code:
  1. Public Sub RenameFile()
  2.  
  3.         Dim mOldFilePath As String = "C:\Sample.txt"
  4.         'Dim mExtension As String
  5.         Dim mNewFileName As String
  6.         mNewFileName = txtName.Text
  7.  
  8.  
  9.         My.Computer.FileSystem.RenameFile(mOldFilePath, mNewFileName)

Thanks in Advance

RCA20