2
I am developing a routine in order to copy files from the server to a local folder, but unfortunately it does not copy. The idea is that every minute the files are copied.
I left one Sleep(5000)
smaller to facilitate testing. There is no domain on the server and the folder on the server is mapped. You could take a look at?
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");
}
}
}
}
What error is occurring ? It is possible that the user running the program is not allowed to access the mapped folder.
– Rafael Marcos
Hello Rafael. I made another routine makes an access to the folder on the server and displays the name of the file in Questa on the screen. It worked perfectly, so I’m not considering the possibility of permission.
– GVGTEC
Shows no error, simply does not copy.
– GVGTEC