C# Windows Service Access denied when trying to write in a folder

Posted by Joseph Ghassan on Stack Overflow See other posts from Stack Overflow or by Joseph Ghassan
Published on 2010-06-07T16:24:47Z Indexed on 2010/06/07 16:32 UTC
Read the original article Hit count: 254

Filed under:
|
|

Hi guys,

I have deployed successfully a C# windows service on a windows 7 machine.

Now, when I try to create a file using this code :

FileStream os = new FileStream(String.Format(folderName, fileName), FileMode.Create);

I get Access to filepath is denied.

In the service Installer I set the following parameters to :

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem; this.serviceProcessInstaller1.Password = "Pass"; this.serviceProcessInstaller1.Username = "Administrator"

I added all the possible accounts with Full permissions to the folder where I want to create the file but nothing helped.

Any suggestions would be highly appreciated

© Stack Overflow or respective owner

Related posts about c#

Related posts about Windows