modernzombie
modernzombie

Reputation: 2049

SpecialFolder.ApplicationData Returning Default User

I am trying to get the path to the currently logged in user's application data folder.

I'm using

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

But the path that is returned is:

C:\Documents and Settings\Default User\Application Data

I want the logged in user not the Default User.

The path I was expecting was:

C:\Documents and Settings\jbezanson\Application Data

This is the path all the websites I've read say I should be getting with that code.

jbezanson is the user I am logged in as.

I am logging into the server via a thin client and terminal services. My application is running on the server. Could this be the problem?

Upvotes: 3

Views: 1780

Answers (3)

JeffH
JeffH

Reputation: 10482

Does jbezanson have FileIOPermissionAccess.PathDiscovery set where the app is running?

Upvotes: 0

John Kraft
John Kraft

Reputation: 6840

The environment class refers to the environment where the application is executing. Without more specific information it is hard to tell. However, if you are in a situation where you are logging into Terminal Services; then executing a thin client; which then connects to a service on yet another machine (or even the same machine), then I'd that there is a high probability that the service application is running as another user (in this case the default user).

Upvotes: 1

llullulluis
llullulluis

Reputation: 3492

I think the problems should be because the user who is executing the server (and then, your application). The server is probably running using network service or local service accounts and those accounts doesn't have application data folder.

Hope this helps.

Upvotes: 2

Related Questions