||If you check the technical documentation for the |
Directory classes you may be a bit alarmed to find that there is no
Rename() method. This method has been left out because you can achieve the same effect by simply using the
Move() method - after all, renaming a file is tantamount to moving it from its original file path to the renamed file path, no?
An example of renaming a file using the
Move() method can be seen below. For more information on
Move() be sure to consult FAQ: How do I copy or move a file from one location to another?.
File class is located in the
System.IO namespace, meaning that you will have to import this namespace into your ASP.NET Web page or code-behind class. If you are using a server-side script block in your ASP.NET Web page, add
<%@ Import Namespace="System.IO" %> to the top of the ASP.NET Web page. If you are using a code-behind class, add the following: