all groups > sql server dts > october 2007 >
You're in the

sql server dts

group:

remove TXT file using DTS package



remove TXT file using DTS package FAHIM
10/2/2007 7:34:10 AM
sql server dts: any idea how to delete the physical file (C:\Test\file.txt) using DTS
package.
Re: remove TXT file using DTS package jhofmeyr NO[at]SPAM googlemail.com
10/2/2007 3:15:57 PM
[quoted text, click to view]

Hi FAHIM,

You can do this using the File System Object (FSO) inside an ActiveX
script task.

Check out http://msdn2.microsoft.com/en-us/library/aa933534(sql.80).aspx
for the basics of how to use ActiveX tasks - it also has examples
using the FSO.
http://msdn2.microsoft.com/en-us/library/z9ty6h50.aspx might also help
- check out the DeleteFile method.

Good Luck!
J
Re: remove TXT file using DTS package GoGoRichie
10/2/2007 4:23:10 PM
[quoted text, click to view]
Make a ActiveX Script Task and include the following
----------------------------------------------------------------------------------------------------
Function Main()
Dim fso, f, f1, fc, s, ReportDate, TempDate, folderspec

folderspec = "C:\Test\file.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
if left(f1.name, 4) = "file" Then
f1.delete(true)
end if
Next
Main = DTSTaskExecResult_Success
End Function
---------------------------------------------------------------------------------------------------
AddThis Social Bookmark Button