bunny
bunny

Reputation: 2037

How to find the path to appdata folder for the logged in user in windows service

I wrote a service and in the code I tried to get the AppData folder's path:

C:\Users\[Username]\AppData\

I tried:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

But I got:

C:\Windows\system32\config\systemprofile\AppData

Upvotes: 0

Views: 1018

Answers (1)

Raja Nadar
Raja Nadar

Reputation: 9499

You're getting the AppData folder of the Account running the service. (System Account) There is no other user involved in it.

If you want a particular user's AppData folder, run the Windows Service under that user's account.

Upvotes: 1

Related Questions