Getting remote machine's WINDOWS path
I need to list files from a remote machine's WINDOWS directory. The programming language I am using is C# and the target OSs are Windows XP and Windows Server 2003. Right now what I am doing is:
开发者_运维技巧filePaths = Directory.GetFiles("\\\\" + machineName + "\\c$\\WINDOWS");
Now, there might be instances where the WINDOWS directory is installed on a drive other than "C:\". This of course would pose problems with the above code.
Anyone got a better solution?
Also, another requirement is for me to read kb*log files (residing in the WINDOWS directory for OS < Vista). Any recommendations as to how I should implement this? I am thinking of using a StreamReader unless there is a better alternative.
TIA!
If you have access to the remote machine's registry, you could read the PathName
variable from the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
System.Environment.GetFolderPath(System.Environment.SpecialFolder.System);
or
Environment.SystemDirectory
精彩评论