June 28, 2006 at 9:08 am
How to dynamically delete a text file through a package?
Scenario: A text file is having a date appended as a suffix to its name. eg. filename06282006.txt If we need to delete the file through package, what should be our plan of action?
Any thoughts appreciated 🙂
June 28, 2006 at 9:10 am
I did it via a VB script task using FileSystemObject.
June 29, 2006 at 7:36 am
FileSystemObject is the way to go. Here is some sample code:
dim fso
dim fil
set fso = CREATEOBJECT("Scripting.FileSystemObject")
set fil = fso.GetFile(DTSGlobalVariables("gv_FileFullName").Value)
'check if file exists in archive location
if fso.FileExists(DTSGlobalVariables("gv_ArchiveLocation").Value & fil.Name) = "True" then
'if file is in the archive folder already, delete archive file
fso.DeleteFile(DTSGlobalVariables("gv_ArchiveLocation").Value & fil.Name)
end if
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply