Solved

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

Posted on 2013-01-16
2
187 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 77

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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