I'm developing a routine for the purpose of copying files from the server to a local folder, but unfortunately it does not copy. The idea is that there are every minute the files are copied.
I left a Sleep(5000)
less to facilitate the test. There is no domain on the server and the folder on the server is mapped. Could you take a look?
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
ThreadStart start = new ThreadStart(CopiarArquivo);
Thread thread = new Thread(start);
thread.Start();
}
protected override void OnStop()
{
}
public void CopiarArquivo()
{
for (int i = 0; i < 600; i++)
{
Thread.Sleep(5000);
File.Copy(@"Z:\PARAM.SAC", @"C:\SACTRM\PARAM.SAC");
}
}
}
}