﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Integration Services  / "Delete files older than X days" error / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 17:03:06 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: "Delete files older than X days" error</title><link>http://www.sqlservercentral.com/Forums/Topic1039629-148-1.aspx</link><description>Has any1 ever used  a long path tool like the one in pathtoodeep.com?</description><pubDate>Thu, 11 Oct 2012 06:02:25 GMT</pubDate><dc:creator>gabrielko_47</dc:creator></item><item><title>RE: "Delete files older than X days" error</title><link>http://www.sqlservercentral.com/Forums/Topic1039629-148-1.aspx</link><description>It seems to be a permission issue. Are you sure permissions on the folder are set up correctly?</description><pubDate>Tue, 28 Dec 2010 08:10:40 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: "Delete files older than X days" error</title><link>http://www.sqlservercentral.com/Forums/Topic1039629-148-1.aspx</link><description>maybe this is shorter and fills in you needs: the maintenance cleanup taskyou can even script it http://sqlblog.com/blogs/andy_leonard/archive/2009/03/11/xp-delete-file.aspx</description><pubDate>Tue, 28 Dec 2010 04:09:14 GMT</pubDate><dc:creator>Marco V</dc:creator></item><item><title>"Delete files older than X days" error</title><link>http://www.sqlservercentral.com/Forums/Topic1039629-148-1.aspx</link><description>Hi,I am using the script task to delete the old files(older than 10 days) present in a particular folder. (D:\FIles)[i]Code to delete the old files:[/i] Dim oFSO        Dim sDirectoryPath        Dim oFolder        Dim oFileCollection        Dim oFile        Dim iDaysOld        'Archive Files        iDaysOld = CInt(Dts.Variables("User::DaysKeepArchive").Value)        'Alter the variable DaysKeepArchive as needed.        oFSO = CreateObject("Scripting.FileSystemObject")        sDirectoryPath = CStr(Dts.Variables("User::ArchiveFiles").Value)        'Alter the variable ArchiveFiles as needed.        oFolder = oFSO.GetFolder(sDirectoryPath)        oFileCollection = oFolder.Files        'Walk through each file in this folder collection.         'If it is older than DaysKeepArchive days, then delete it.        For Each oFile In oFileCollection            If oFile.DateLastModified &amp;lt; (DateTime.Now.AddDays(-iDaysOld)) Then                oFile.Delete(True)            End If        Next        'Clean up        oFSO = Nothing        oFolder = Nothing        oFileCollection = Nothing        oFile = Nothing        Dts.TaskResult = Dts.Results.Success[b]But i am getting the following error when execute it :[u][/u][/b]Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)   at ScriptTask_c546ddcc3bdc4c85a39194f9edce9ca6.ScriptMain.Main() in dts://Scripts/ScriptTask_c546ddcc3bdc4c85a39194f9edce9ca6/ScriptMain:line 41Can somebody help on this.THANKS in Advance.</description><pubDate>Mon, 27 Dec 2010 22:20:54 GMT</pubDate><dc:creator>marees.inspire</dc:creator></item></channel></rss>