每当我的应用程序尝试将文件复制到C:\\ Users \\ ??? \\ AppData \\ Local时,我得到“拒绝访问文件路径”即使我使用管理员运行应用程序它仍然无法正常工作,有人帮忙吗?
You'll get a Access to the path '...' is denied
error if the folder is flagged ReadOnly
. You could try to remove this flag prior to copying the file.
Dim info As DirectoryInfo = New DirectoryInfo("C:\Users\???\AppData\Local")
If (info.Exists AndAlso ((info.Attributes And FileAttributes.[ReadOnly]) = FileAttributes.[ReadOnly])) Then
info.Attributes = (info.Attributes Xor FileAttributes.[ReadOnly])
End If
Update
I did a google search and found these link which seems interesting:
"Those are junction points : hidden, protected operating system files that are not meant to be accessed by users. Each one points to a user-accessible folder:"
"These junction points can be identified as follows:"
So...
I don't know if this is recommended, will work or throw an error, but you could try to remove these flags:
info.Attributes = (attributes Xor (FileAttributes.ReparsePoint Or FileAttributes.Hidden Or FileAttributes.System))
And add then back afterwards:
info.Attributes = (attributes Or (FileAttributes.ReparsePoint Or FileAttributes.Hidden Or FileAttributes.System))
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.