c# - Issue to move file from one folder to another using window service, running as NetworkService -


i want move .txt file 1 folder when window service starting up.

protected override void onstart()     {         string sourcefile = @"d:\source\file.txt";         string destinationfile = @"d:\destination\file.txt";         file.move(sourcefile, destinationfile);     } 

this code working when serviceprocessinstaller1 accunt type localsystem. if change serviceprocessinstaller1 accunt type networkservice, error access path denied. me solve issue ?

your problem here user permissions in machine. try changing permissions file , folder , set them less restricted. i'm sure if set permissions users, service work. it's risky too.

in this page, "file access" section, can read how configure permissions.


Comments