July 30, 2003 at 8:56 am
In my DTS pkg, I am using FSO to check if the file exist and if it does I want to save it with different name. Is there a "Save As" function in File System Object?
July 30, 2003 at 9:23 am
Not as far as I know...however, it is easier than you think to rename the file...
Dim objfso
Set objfso = CreateObject("Scripting.FileSystemObject")
Dim objfile
If objfso.FileExists(("\\myserver\myfiles\myfile.txt")
) Then
objfile.copyfile "\\myserver\myfiles\myfile.txt", "\\myserver\myfiles\newfilename.txt"
'CopyFile method will leave the original file intact...if you want to delete it, uncomment the following line:
'objfile.deletefile "\\myserver\myfiles\myfile.txt"
End If
Something like that should work...hope this helps! Look up FileSystemObject on MSDN or search on google..lots of good examples out there...
hth,
Michael
End If
Michael Weiss
Michael Weiss
July 30, 2003 at 9:25 am
oops...let me correct that piece of code...it should be:
Dim objfso
Set objfso = CreateObject("Scripting.FileSystemObject")
If objfso.FileExists(("\\myserver\myfiles\myfile.txt")
) Then
objfso.copyfile "\\myserver\myfiles\myfile.txt", "\\myserver\myfiles\newfilename.txt"
'CopyFile method will leave the original file intact...if you want to delete it, uncomment the following line:
objfso.deletefile "\\myserver\myfiles\myfile.txt"
End If
Michael Weiss
Michael Weiss
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply