Solved

What is the Best practice to copy files to local folder from a remote website

Posted on 2013-01-16
2
182 Views
Last Modified: 2013-03-26
I would be glad to know the best practice to copy some image files periodically (every 10 minutes) based on a certain pattern of file names in a particular directory from a remote website's directory.

Options:
1. In an SSIS package or
2. In .NET library or any other ideas??

Thanks in advance!!
0
Comment
Question by:InquisitiveMind
2 Comments
 
LVL 76

Expert Comment

by:arnold
ID: 38785242
why are you running a task out SQL rather than running it as a scheduled task?
your script vb or c# can access the database if needed to identify paths without wasting SQL server resources.
0
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 500 total points
ID: 38793840
If it is going to be running all the time I wouldn't do a scheduled task, personally I would do the below:

I would create a .Net library which is called by a .Net Windows Service, you can set this to run every 10 minutes via a timer.  For example:

namespace MyFileService
{
    public partial class MyService : ServiceBase
    {
        private Timer _systemTimer;

        public MyService()
        {
            InitializeComponent();
            this.ServiceName = "MyService";
            this.AutoLog = true;
            this.CanPauseAndContinue = false;
            _systemTimer = new Timer(600000); // 10 minutes
            _systemTimer.Elapsed += _systemTimer_Elapsed;
        }

        void _systemTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                _systemTimer.Stop();
		// Start moving or copying the files
		// DirectoryInfo di.....
       			
            }
            catch (Exception ex)
            {
                // handle your error
            }
            finally
            {
                _systemTimer.Start();
            }
        }

        protected override void OnStart(string[] args)
        {
            _systemTimer.Start();
        }

        protected override void OnStop()
        {
            _systemTimer.Stop();
            _systemTimer.Dispose();
        }
    }
}

Open in new window

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Loop through Multiple Processes Async 2 17
Mssql SQL query 14 28
BULK INSERT most recent CSV 19 21
SqlAdvisor 2016 3 5
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now