Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 C# 中,如何引用以下位置而不是硬编码它们?
您可以使用:
System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles);
获取机器上的程序文件文件夹。这将返回对正在运行的应用程序正确的任何内容。因此,对于 64 位机器上的 32 位应用程序,它将在英文版 Windows 上返回“C:\Program Files (x86)”。