I'm programming in C#/.NET. I want to be able to return the Program Files directory from the target machine no matter what the architecture of the target machine is. To clarify, I want it to return C (or whatever drive the OS is on):/Program Files
no matter what bitness their version of Windows is.
I could just hardcode in the directory except if the user was running Windows that's not installed on the C: drive it wouldn't work.
I found
FileInfo(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles)
but I think it returns the Program Files (x86)
folder on a 64 bit windows machine.
System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles)
在64位计算机上返回"c:\\Program Files"
,除非代码是针对目标x86构建的,在这种情况下它返回"C:\\Program Files (x86)"
,所以我想这对你有用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.