0

I'm trying to copy excel file from server shared folder to local system folder using windows service C#. But throw below error

The Microsoft Access database engine cannot open or write to the file It is already opened exclusively by another user, or you need permission to view and write its data.

Code:

string filename = @"\\Datawarehouse\Data\Result.xlsx";
string filePath = @"C:\Test\Result.xlsx";
System.IO.File.Move(filename , filePath);
Filburt
  • 17,626
  • 12
  • 64
  • 115
  • Have you already tried the solution below? [enter link description here](https://stackoverflow.com/questions/44061573/the-microsoft-office-access-database-engine-cannot-open-or-write-to-the-file) – encoder93x Dec 26 '21 at 12:54
  • @encoder93x, tried but not working. Permission also provide to this service account read/write – Time Attendance System Dec 26 '21 at 13:12
  • `File.Move` will never give you the error you wrote. So which code throws this exception? – Steeeve Dec 26 '21 at 17:56

1 Answers1

1

The error you are showing can be caused by a few causes:

  1. The file you are attempting to open a file which still is open on your machine (or if it is in the cloud then someone still has it open)

  2. If the file is in the cloud, then it could be caused by security settings so you can try to move the file locally onto the server.

  3. If the file is local then it could be caused by permissions issues, you can try and grant the user "Everyone" to test if this resolves the error.

Ran Turner
  • 14,906
  • 5
  • 47
  • 53