删除文件system.io.file.delete(path)时出错 [英] error while deleting a file system.io.file.delete(path)

查看:560
本文介绍了删除文件system.io.file.delete(path)时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在程序中使用system.io.file.delete(path)并运行它时遇到问题。它引发了一个异常,告诉访问被拒绝到该路径如何解决这个问题请帮助

提前谢谢

i have a problem when i use system.io.file.delete(path) in my program and run it. it raises an exception telling access denied to that path how do i resolve this issue please help
thank you in advance

推荐答案

你需要查看您的文件夹,看看为哪些人分配了哪些权限:尝试使用Windows资源管理器,然后右键单击该文件夹。选择属性,然后选择安全选项卡。你可以检查和更改那里的权限。除非您的应用程序正在运行的用户具有修改权限,否则您将无法删除代码中的文件。
You need to look at your folder and see what permissions are assigned for what people: try with Windows Explorer, and right click the folder. Select "Properties" and then the "Security" tab. you can inspect and change the permissions there. Unless the user that your application is running as has "Modify" permission, you will not be able to delete the file in your code.


我终于找到了解决问题的方法

它可以正常使用此代码



i finally found a solution to my problem
it works fine with this code

Dim s As String
For Each s In System.IO.Directory.GetFiles("C:\WINDOWS\TEMP")
System.IO.File.Delete(s)
Next s


这篇关于删除文件system.io.file.delete(path)时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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