2
Reply

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

Sumit Kumawat

Sumit Kumawat

Oct 27 2012 12:41 AM
4.2k

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)