“访问被拒绝的路径”当我尝试删除文件夹时 [英] "Access to the path denied" when I try to delete a folder

查看:99
本文介绍了“访问被拒绝的路径”当我尝试删除文件夹时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我对vb.net有疑问。

当我尝试删除文件夹时 - 访问拒绝的路径



此处代码:

Hi everyone, I have problem with vb.net.
When I try to delete a folder - "Access to the path denied"

here code:

Dim path As String = "C:\Users\" + SystemInformation.UserName + "\AppData\Local\Test"

        If Directory.Exists(path) Then

            Directory.Delete(path, True)
        Else
            Console.WriteLine(path & " not exists")
        End If





请帮助!



Please help!

推荐答案

您需要以管理员权限运行程序。您无权删除该文件夹。
You need to run your program with administrator privileges. You do not have permissions to delete the folder.


错误消息足够清晰。您没有权限 [ ^ ]删除特定文件夹。请参阅:拒绝访问指定的设备,路径或文件。 [ ^ ]



BTW:我强烈建议使用 DirectoryInfo类 [ ^ ]。
The error message is clear enough. You have no permissions[^] to delete specific folder. See: Access to the specified device, path or file is denied.[^]

BTW: i'd strongly recommend to use DirectoryInfo class[^].


这篇关于“访问被拒绝的路径”当我尝试删除文件夹时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆