'Cannot to access network path (UNC) using AD service account in console application

I am running a console application using task scheduler to read files from a shared network drive. The account running the application is a AD service account. When I try to access the network resources, it is throwing access denied error. The service account has necessary permissions to read the data from the network drive. Need insights on what exactly is going wrong.

var files =  Directory.GetFiles(drivePath);

For some reason it works with my personal account which has access to the drive. Also I am able to map the drive using the service account which shows that the account has necessary permissions. Need insights on what could be wrong, as I am new to using network drives in .NET



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source