0

I have a service which copies an Excel spread sheet from a network share to a local folder. The service runs under an account which has admin rights on both the remote and local machine.

When running the service from the command line as the service admin account the file copy succeeds. However, when running the service as a windows service, the file copy fails, and does so silently.

So there are two problems;

  1. Why does the service behave differently between the command line and windows services, even though they are both being run under the same admin account?
  2. Why does the file copy fail silently when the msdn documentation suggests this is not possible?

Simplified code:

try
{
    File.Copy(@"\\share\folder\file.xlsm", @"C:\temp\file.xlsm");
}
catch (Exception ex)
{
     Logger.Error("error");
}
Tom
  • 679
  • 1
  • 6
  • 15
  • What happens if source file is on local disk? – Dialecticus Oct 06 '15 at 09:41
  • What is the exception? `Logger.Error(ex.Message)`. – Richard Schneider Oct 06 '15 at 10:05
  • @RichardSchneider There is no exception. That's the point. – Tom Oct 06 '15 at 10:07
  • Then the code is never being executed. You have a problem somewhere else. – Richard Schneider Oct 06 '15 at 10:08
  • @RichardSchneider the code is being executed - I added logging before and immediately after the copy operation in the production version of the code. The original code is not my own though. Starting to wonder if another thread/process is deleting the copied file as it's intended to be temporary. Wouldn't explain the different behaviour between the command line and windows service. – Tom Oct 06 '15 at 10:26

0 Answers0