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.
我正在尝试将文件复制到 System32 文件夹。我试过了;
System.Environment.ExpandEnvironmentVariables("%windir%\system32") Environment.GetFolderPath(Environment.SpecialFolder.System)
它没有用。它总是返回到 C:/Windows 。我应该怎么做才能获得 System32 文件夹?谢谢。
这两个都有效。您可以通过在方法的第 2 行设置断点Button1_Click然后检查dir.
Button1_Click
dir
话虽如此,您真的不应该写入 System32 文件夹(或者实际上是 Windows 文件夹中的任何内容,Temp 除外)。如果您尝试在最终用户计算机上安装应用程序,则应该使用安装程序(并写入 Program Files 文件夹)。
通常不允许直接写入 System32 文件夹(除非您关闭了访问控制和许多安全功能),因为它会带来巨大的安全风险。由于可能(或可能不)存在不同的安全控制,您也不能保证它甚至可以在所有系统上运行。