Rename files using the FileSystemObject

You may have noticed that the FileSystemObject doesn't have a Rename method anywhere in its object model. This does not, however, mean that you can't rename a file. The answer lies in the realization that you can use the MoveFile method, specifying two different file names in the same directory. A sample of this technique is shown below:

<%
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   fso.MoveFile "d:\dummytest.txt", "d:\dummytest2.txt"
%>

You might also like...

Comments

ElementK Journals

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There's no test like production” - Anon