Changing filename inside a directory RRS feed

  • Question

  • using vb.net 2005.  how do i change the name of a file inside a directory?  I want to change the name of the file and save that change so the file will have a new name. thanks.
    Wednesday, May 30, 2007 6:17 PM


  • You can use the Move method to move the file from one name to another.. this is the same as renaming...


    The My namespace also has a method for renaming files. They both do the same thing..


    Code Snippet

    System.IO.File.Move("C:\somedirectory\somefile.txt", "C:\somedirectory\somefilenewname.txt")

    My.Computer.FileSystem.RenameFile("C:\somedirectory\somefile.txt", "C:\somedirectory\somefilenewname.txt")


    Wednesday, May 30, 2007 6:47 PM