Sumit Kumawat

Sumit Kumawat

  • NA
  • 454
  • 414.6k

window service is giving different file path while accessing path from the Environment.SpecialFolder.ApplicationData

Oct 27 2012 12:41 AM

Hi all

in my app i am providing path using  Environment.SpecialFolder.ApplicationData for my connection string,

i.e: string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\TestFolder\" + "test.sdf";

and its returning the following path :

"C:\Users\sumitk\AppData\Roaming\TestFolder\test.sdf";

and its working fine for my window C# app.

same like this if  i use Environment.SpecialFolder.ApplicationData in my window service for accessing the database its giving me the following path

"C:\Windows\system32\config\systemprofile\AppData\Roaming\TestFolder\test.sdf"

due to this i am not able to access my database through window service and its giving me below error :

" Check the directory for the database. [ Path = C:\Windows\system32\config\systemprofile\AppData\Roaming\TestFolder\test.sdf ]"

so plz tell me how can i access the same path through my window service  which is i am getting from my C#app


sumitk


Answers (2)