复制目录在 C:\Windows\System32\spp\store 中不起作用
Copy Directory not work in C:\Windows\System32\spp\store
我正在尝试从我的程序中复制此目录,当我尝试时它告诉我,"the path does not exist"。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
My.Computer.FileSystem.CopyDirectory("C:\Windows\System32\spp\store", "D:\store", True)
End Sub
如果您的应用程序是 64 位系统上的 32 位应用程序,那么您正在体验所谓的 File system redirection。
由于32位应用无法加载64位dll,64位应用无法加载32位dll,所以64位系统有两个系统文件夹:
System32
- 带有 64 位 dll 的 64 位版本,并且:
SysWOW64
- 带有 32 位 dll 的 32 位版本。
对于所有尝试访问 System32
文件夹的 32 位应用程序,文件系统重定向器会自动将 %SystemRoot%\System32
重定向到 %SystemRoot%\SysWOW64
,因此您无法复制该目录的原因是因为它SysWOW64
文件夹中不存在。
您可以通过三种方法克服这个问题。我按照第一个最推荐,最后一个最不推荐的顺序列出它们:
改用 SysNative
文件夹。
您可以使用 C:\Windows\SysNative
而不是 C:\Windows\System32
,这会将 32 位应用程序带到 原始 System32
文件夹。
If Environment.Is64BitOperatingSystem = True AndAlso Environment.Is64Process = False Then 'Is this a 32-bit app in a 64-bit system?
My.Computer.FileSystem.CopyDirectory("C:\Windows\SysNative\spp\store", "your destination path here")
Else 'This is either a 64-bit app in a 64-bit system, or a 32-bit app in a 32-bit system.
My.Computer.FileSystem.CopyDirectory("C:\Windows\System32\spp\store", "your destination path here")
End If
在 64 位模式或 AnyCPU
下编译您的应用程序。
通过 P/Invoking 和 Wow64DisableWow64FsRedirection()
function 禁用文件系统重定向。 (我真的不推荐这样做,因为如果您的应用程序试图从系统目录加载 dll,事情可能会中断)。
我正在尝试从我的程序中复制此目录,当我尝试时它告诉我,"the path does not exist"。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
My.Computer.FileSystem.CopyDirectory("C:\Windows\System32\spp\store", "D:\store", True)
End Sub
如果您的应用程序是 64 位系统上的 32 位应用程序,那么您正在体验所谓的 File system redirection。
由于32位应用无法加载64位dll,64位应用无法加载32位dll,所以64位系统有两个系统文件夹:
System32
- 带有 64 位 dll 的 64 位版本,并且:SysWOW64
- 带有 32 位 dll 的 32 位版本。
对于所有尝试访问 System32
文件夹的 32 位应用程序,文件系统重定向器会自动将 %SystemRoot%\System32
重定向到 %SystemRoot%\SysWOW64
,因此您无法复制该目录的原因是因为它SysWOW64
文件夹中不存在。
您可以通过三种方法克服这个问题。我按照第一个最推荐,最后一个最不推荐的顺序列出它们:
改用
SysNative
文件夹。您可以使用
C:\Windows\SysNative
而不是C:\Windows\System32
,这会将 32 位应用程序带到 原始System32
文件夹。If Environment.Is64BitOperatingSystem = True AndAlso Environment.Is64Process = False Then 'Is this a 32-bit app in a 64-bit system? My.Computer.FileSystem.CopyDirectory("C:\Windows\SysNative\spp\store", "your destination path here") Else 'This is either a 64-bit app in a 64-bit system, or a 32-bit app in a 32-bit system. My.Computer.FileSystem.CopyDirectory("C:\Windows\System32\spp\store", "your destination path here") End If
在 64 位模式或
AnyCPU
下编译您的应用程序。通过 P/Invoking 和
Wow64DisableWow64FsRedirection()
function 禁用文件系统重定向。 (我真的不推荐这样做,因为如果您的应用程序试图从系统目录加载 dll,事情可能会中断)。