Skip to content


Deleting Source Files from Archive Folder

One question that can come up in SmartConnect is, “How can we delete source files that have been moved into a folder, such as an archive folder”?

This can be done by creating a task that runs before the map. We can create this task by clicking on the Tasks tab on the Map Setup window.

Then we can right click on “Tasks that run before the map”, select New Task -> Run Script.



This will open a window where we can write a script to delete these files using .Net code.



In this example, we will include logic on deleting files that are older than X number of days.

Unless you are familiar coding in .NET, this will take some research to figure out how to write it.

Below is some sample code to delete files older than 10 days. We can change the days value as needed for the specific requirements.

















As we can see in the code above, we will be able to set the directory to wherever the files we want to be deleted are stored.

The code will run through each file in that directory and delete it, if it is older than 10 days.

This is a very useful option to save space since these files have already been integrated. It also saves time by not having to manually

go and delete all these files every day.


Delete Files with a Certain Extension

What if we want to delete files like above, but only files with a certain extension. We can do this by updating our

.NET code from above. Let’s say that we want to delete files older than X amount of days that have a file extension “.txt”.

We can do this by adding one piece to the .NET code above. As we can see below, we added what file extension to delete behind the “GetFiles” function.



This script will now only grab files that have a “.txt” extension and delete the file if it is older than 10 days.

This is also a great option, since we may have other files in our folder that we do not want to delete.






RECENT POSTS Inactivity Timeout error running integration
SmartConnect ODBC query error - Restricted data type attribute violation
Message #24574 is missing
Your registered version of SmartList Builder does not match the installed version of SmartList Builder.
How to Pay for a Product Renewal or Create a Quote


SSL Security error using OLEDB Connection
This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms
Removed Part: /xl/vbaProject.bin part. (Visual Basic for Applications (VBA))
The server process could not be started because the configured identity is incorrect.
Using WINSCP and a task to upload or download files from an SFTP site



Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships Partner All Hands Call Popdock promotions release SalesForce SmartConnect SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.