Welcome to Dream.In.Code
Become a VB Expert!

Join 150,156 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,370 people online right now. Registration is fast and FREE... Join Now!




How to copy, delete, move, and rename file in VBScript

 
Reply to this topicStart new topic

How to copy, delete, move, and rename file in VBScript

jacobjordan
14 Jul, 2008 - 10:48 AM
Post #1

class Me : Perfection
Group Icon

Joined: 11 Jun, 2008
Posts: 1,262



Thanked: 39 times
Dream Kudos: 1675
My Contributions
Wish i had code to show, but can't even get started. I hope this was the right forum to post this in. I need to know how to perform basic file IO operations in VBScript (copy, delete, move, ect.). I have never used VBScript before, so any advice for a tutorial would be great too.
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: How To Copy, Delete, Move, And Rename File In VBScript
14 Jul, 2008 - 11:35 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Are you doing this in a .VBS file, or in Classic ASP? You're going to want to use the FileSystemObject for this. To copy a file in classic ASP use


vb

Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "C:\MyTestFile.txt", "C:\TestFolder\MyTestFile.txt"
Set FSO = nothing

User is offlineProfile CardPM
+Quote Post

jacobjordan
RE: How To Copy, Delete, Move, And Rename File In VBScript
14 Jul, 2008 - 12:07 PM
Post #3

class Me : Perfection
Group Icon

Joined: 11 Jun, 2008
Posts: 1,262



Thanked: 39 times
Dream Kudos: 1675
My Contributions
I'm using a .VBS file.

This post has been edited by jacobjordan: 14 Jul, 2008 - 12:07 PM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: How To Copy, Delete, Move, And Rename File In VBScript
14 Jul, 2008 - 03:13 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
You're still going to want to use the FileSystemObject for this, that is the class that will do all of this for you (the link I offered in my original post will show all the methods available, as will this site). The modification to make from my above example is to remove the Server. in the code

vb

Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "C:\MyTestFile.txt", "C:\TestFolder\MyTestFile.txt"
Set FSO = nothing

User is offlineProfile CardPM
+Quote Post

jacobjordan
RE: How To Copy, Delete, Move, And Rename File In VBScript
14 Jul, 2008 - 03:17 PM
Post #5

class Me : Perfection
Group Icon

Joined: 11 Jun, 2008
Posts: 1,262



Thanked: 39 times
Dream Kudos: 1675
My Contributions
Thanks, that helps. I assume it can do more than just copy files, so i will try to figure out how to do the other things i want with it.
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: How To Copy, Delete, Move, And Rename File In VBScript
14 Jul, 2008 - 04:11 PM
Post #6

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
@jacobjordan: If you will read those two links I provided they will show all that is possible with the FileSystemObject. It's actually quite powerful and will do all of what you're looking for
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:39AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month