Use namespace System.IO
VB.NET
File.Move('C:\Dir1\SomeFile.txt', 'C:\Dir1\RenamedFileName.txt')
C#
File.Move(@'C:\Dir1\SomeFile.txt', @'C:\Dir1\RenamedFileName.txt')
Refer
Note: In a Web application, the code is running in the context of the machine\ASPNET account, which has limited privileges. If the error you are getting pertains to permissions, you might need to grant to the machine\ASPNET account the rights to create and delete files in the directory where you’re working. Note that this could be a security issue.
Share with