VB程序文件访问需要尽快提出建议..... [英] VB Program file access NEED ADVICE ASAP.....

查看:85
本文介绍了VB程序文件访问需要尽快提出建议.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一种简单的获取文件方法,但是由于被检查的文件路径被拒绝访问,扫描停止了.如何设置程序对计算机中的所有文件具有完全访问权限.

代码如下

I have used a simple get file method but the scan stops because the file path being checked is access denied. How can I set the program to have full access to all files in the computer.

the code is as follows

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 &= String.Format("{0}Couldn't delete infected file: {1}", Environment.NewLine, 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



预先谢谢您.



thank you in advance

推荐答案

该软件将在您的帐户(启动该应用程序的用户帐户)下执行.这也意味着该应用程序具有与该用户相同的权限.因此,要访问这些文件,您需要提供对该帐户的访问权限.

您了解,否则将无法在操作系统中建立任何安全性.但是,幸运的是,大多数人并没有使用实际的操作系统,而是使用Windows(有病毒,并且不要忘记病毒扫描程序所在的地方;-))

您可能已经注意到,病毒或病毒扫描程序(没有实际区别)不是单独起作用,并且具有用于执行不同任务的多个进程.诀窍在于,在大多数情况下,应用程序可以访问Internet,但无法访问所有系统.对于Windows,这意味着还存在一个无法访问Internet/网络但可以访问系统其余部分的帐户.听起来应该不错吧?因为对于您的病毒扫描程序,您可以使用它...但是同样,您或其他任何人也可以将其用于病毒开发:-D.您可以使用LocalSystem.一项不错的服务为本地系统管理"提供权利,例如为某些其他事情提供用户模式应用程序的权利.这仅需要某种简单的通信机制,您便可以将两个世界的共同权利带到这里!太好了! ;)

祝你好运!
The software will be executed under your account (account of the user that starts the application). This also means that the application has the same rights as that user. So, to get access to these files you would need to provide access to that account.

You understand that otherwise there would be no security what so ever built in the OS. But, luckily most people don''t use an actual OS but they use Windows (the place where viruses and, not to forget, virus-scanners live;-))

As you might have noticed a virus or virus-scanner (there is no actual difference) is not working alone and has several processes for different tasks. The trick is that an application, in most cases, have Internet access but cannot access all of the system. For windows this means that there is also an account that does not have internet/network access but does has access to the rest of the system. Should sound very good right? Because for your virus scanner you could use this... but likewise you, or anyone else, can use this for virus development :-D . LocalSystem is something you could use. A nice service supplies rights for local "system administration" and for example a user mode application for some other things. This only needs a simple communication mechanism of some sort and there you go, the combined rights of both worlds! Isn''t it great! ;)

Good luck!


这篇关于VB程序文件访问需要尽快提出建议.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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