Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

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

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
InquisitiveMind
Asked:
InquisitiveMind
1 Solution
 
arnoldCommented:
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
 
angus_young_acdcCommented:
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now