拒绝访问路径"C:\ Documents and Settings \". [英] Access to the path 'C:\Documents and Settings\' is denied.

查看:66
本文介绍了拒绝访问路径"C:\ Documents and Settings \".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在程序中使用了get file方法,但需要调整程序访问权限,以便能够扫描整个根目录.

这是提供给我的代码

 导入 System.IO
公共  Form1
    私有  Sub  btnScan_Click( ByVal 发​​件人 As 系统.对象 ByVal  e  As  System.EventArgs)句柄 btnscan.Click
        btnscan.Enabled = 错误
         Dim  searchForTheseFiles() As  字符串 = txtFileList .Text.ToUpper.Split(Environment.NewLine)
         Dim 文件列表 As  新建列表( Of  字符串)(searchForTheseFiles)
         Dim  myDir  As  新建 DirectoryInfo(cboDriveList.文本)
        对于 每个 foundFile  As  FileInfo  myDir.GetFiles(" , SearchOption.AllDirectories)
        如果 fileList.Contains(foundFile.Name.ToUpper)然后
            MsgBox(" )

            textbox1.Text& = Environment.NewLine& foundFile.FullName
            尝试
                foundFile.Delete()
            捕获,例如 As 异常
                MsgBox(" )
                textbox1.Text& = Environment.NewLine& " & foundFile.FullName
            结束 尝试
        结束 如果
        下一步 foundFile
        btnscan.Enabled = 真实
    结束 

    私有 功能 foundFile() As  对象
        抛出 新建 NotImplementedException
    结束 功能

    私人  Form1_Load( ByVal 发​​件人 As 系统.对象 ByVal  e  As  System.EventArgs)句柄  MyBase  .Load
        cboDriveList.Items.AddRange(System.IO.Directory.GetLogicalDrives)
    结束 
结束  




请对此做任何更正或建议

我有一个组合框来选择根目录,一个开始扫描按钮,一个具有给定名称的文本文件以进行搜索.它可能会强制其自身为只读,请使用System.Security.Permissions.FileIOPermission将其更改为读/写,然后尝试删除该
如果失败,则可以尝试将文件移动到另一个目录并重命名,以便所有引用文件都找不到它,也可以尝试删除整个目录,这可能会起作用.
祝您好运,并拥有这款抗病毒软件.我讨厌该死的东西.


I have used a get file method in my program but need to adjust my program access to be able to have the privileges to scan the entire root directory

Here is the code provided to me

Imports System.IO
Public Class Form1
    Private Sub btnScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnscan.Click
        btnscan.Enabled = False
        Dim searchForTheseFiles() As String = txtFileList.Text.ToUpper.Split(Environment.NewLine)
        Dim fileList As New List(Of String)(searchForTheseFiles)
        Dim myDir As New DirectoryInfo(cboDriveList.Text)
        For Each foundFile As FileInfo In myDir.GetFiles("*.*", SearchOption.AllDirectories)
        If fileList.Contains(foundFile.Name.ToUpper) Then
            MsgBox("AAAAAHHHHH!!!! VIRUS FOUND!!!")

            textbox1.Text &= Environment.NewLine & foundFile.FullName
            Try
                foundFile.Delete()
            Catch ex As Exception
                MsgBox("Couldn't delete infected file!")
                textbox1.Text &= Environment.NewLine & "Couldn't delete infected file: " & foundFile.FullName
            End Try
        End If
        Next foundFile
        btnscan.Enabled = True
    End Sub

    Private Function foundFile() As Object
        Throw New NotImplementedException
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cboDriveList.Items.AddRange(System.IO.Directory.GetLogicalDrives)
    End Sub
End Class




please make any corrections or suggestions to this

I have a combobox to select the root dir, a start scan button, a text file with the given names to search for.

解决方案

If its a virus theres a chance it might be forcing itself to be readonly, use System.Security.Permissions.FileIOPermission to change it to read/write and try deleting that
If this fails, you can try moving the file to another directory and renaming it so any referencing files cant find it you can also try deleting the whole directery, might work..

Best of luck with this anti virus. i hate the damn things.


这篇关于拒绝访问路径"C:\ Documents and Settings \".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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