1)how can i find out the Windows Installation drive in which the user
is working.?
var systemDrive = Environment.ExpandEnvironmentVariables("%systemdrive%");
I need this to navigate to the ApplicationData in
DocumentsandSettings.
You don't really require to fetch the value of either system drive or currently logged in user name to achieve this. There are predefined environment variables %localAppData%
and %appData%
which give you fully qualified path of these directories as shown in the code below:
var localApplicationData = Environment.ExpandEnvironmentVariables("%localappdata%");
//this gives C:\Users\<userName>\AppData\Local
var roamingApplicationData = Environment.ExpandEnvironmentVariables("%appdata%");
//this gives C:\Users\<userName>\AppData\Roaming
2)Also how can i get the user name too so that i can goto
ApplicaitionData.? Eg: "D:\Documents and Settings\user\Application
Data".
Again, you don't need user name to get the application data path as I've discussed above. Still, for the sake of knowledge you can fetch it from %username%
environment variable as shown below:
var currentUserName = Environment.ExpandEnvironmentVariables("%username%");