请我在边缘帮助!!!!! [英] Please Im On the edge HELP!!!!!!!

查看:77
本文介绍了请我在边缘帮助!!!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧......整个星期我一直在努力寻找对所有文件夹和子文件夹进行搜索的rec恼,我完全不了解它,所以我在这里问了几个问题并得到了答复我可以使用get files方法来搜索整个目录(例如C:\),以查找所需的文件.这里的问题是我对细节的无知.……我需要知道将代码放置在哪里,以便允许用户从组合框(如c,d,e,fect)中选择一个根目录,然后按下开始,以检查计算机中文本文件中列出的名称. :(

我的代码来自MSDN网站

Well here goes........ All week I have been trying to figure out recrusion to search all folders and subfolders to no luck do I fully understand it so I asked a few questions here and got the responce that I can use the get files method to search an entire dir such a C:\ for the file im looking for. the problem here is my ignorance to details....... I need to know where to place this code so that it will allow the user to select a root dir from a combobox like c,d,e,f ect and then press start to check the computer for names listed in a text file......MY GOD SOMEONE PUT AN END TO MY SUFFERING!! :(

the code I have is from the MSDN website

Imports System
Imports System.IO
Imports System.Collections

Public Class form1


    ' For Directory.GetFiles and Directory.GetDirectories
    ' For File.Exists, Directory.Exists

    Public Overloads Shared Sub Main(ByVal args() As String)
        Dim path As String
        For Each path In args
            If File.Exists(path) Then
                ' This path is a file.
                ProcessFile(path)
            Else
                If Directory.Exists(path) Then
                    ' This path is a directory.
                    ProcessDirectory(path)
                Else
                    Console.WriteLine("{0} is not a valid file or directory.", path)
                End If
            End If
        Next path
    End Sub 'Main


    ' Process all files in the directory passed in, recurs on any directories
    ' that are found, and process the files they contain.
    Public Shared Sub ProcessDirectory(ByVal targetDirectory As String)
        Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
        ' Process the list of files found in the directory.
        Dim fileName As String
        For Each fileName In fileEntries
            ProcessFile(fileName)

        Next fileName
        Dim subdirectoryEntries As String() = Directory.GetDirectories(targetDirectory)
        ' Recurs into subdirectories of this directory.
        Dim subdirectory As String
        For Each subdirectory In subdirectoryEntries
            ProcessDirectory(subdirectory)
        Next subdirectory

    End Sub 'ProcessDirectory

    ' Insert logic for processing found files here.
    Public Shared Sub ProcessFile(ByVal path As String)
        Console.WriteLine("Processed file '{0}'.", path)
    End Sub 'ProcessFile
End Class 'RecursiveFileProcessor




但是我该如何使用以下内容进行操作

3.您选择的按钮可能会开始停止和删除
1. devexpress中的1.combobox复选框
1或2个文本或列表框

还有什么吗?

请给我一些可以配合的东西,这样我就可以摆脱这个噩梦了

再次感谢人们.....


我想我需要尽我所能重新表达我的问题

1)用户在组合框中选择一个根目录(例如.... C:\)
2)将带有病毒名称的文本文件加载到文本框中,以供用户查看
3)启用开始扫描,搜索进入根目录中的每个文件夹,直到文本文件完成
4)文本文件中匹配的搜索结果显示在文本或列表框中,供用户查看和删除-Dale Seeley 3分钟前




but how do i make this work with the following

3.buttons of your choice perferably start stop and delete
1.combobox checkbox from devexpress
1 or 2 text or list boxes

anything else?

please please give me something to work with so I can move on from this nightmare

thanks again people.....


I think I need to re phrase my question the best i can

1) the user selects a root dir in the combobox (example....C:\)
2) the text file with the virus names is loaded into a textbox for the user to see
3) start scan is enabled and the search goes into every folder in the root dir untill the text file is done
4) the matched search results from the text file are shown in a text or listbox for the user to review and delete - Dale Seeley 3 mins ago

推荐答案

第1点.
3个按钮,
为此,我将使用异步方法,因为您可以在它们未完成时停止它们的执行,而且它们不会挂断您的代码-这非常容易使用-- 或列表框,也许要显示所有搜索结果? listbox1.items.add(ProcessDirectory(Combobox1.SelectedItem.Text));


嗯,希望您能得到所有..不确定是否能帮到您,但希望您能朝正确的方向发展.
point 1.
3 buttons,
for this i''d use Asyncronous methods, as you can stop them executing when their not finished, plus they''l not hang up your code - its quite easy to use em - http://www.google.com/url?url=http://www.codeproject.com/KB/cs/AsyncMethodInvocation.aspx&rct=j&sa=U&ei=4gq8TP7nBsH88Abk75HuDg&ved=0CBUQFjAA&q=asynchronous+methods+c%23&usg=AFQjCNFwjmvXcH5684HLzc514ge2eWt10w&cad=rj[^]

start would be beginInvoke(svc.searchMethodName), Stop would be svc.Abort(), and delete? for files? need to import system.IO and use File.Delete whenever the file itself is returned back.

the combobox? i dont undertstand if this is what you want, but if you import (using system.Environment) you can use a method called "GetLogicalDrives()" - then add the returned array to your combobox.
or the list box, maybe to show all the search results? listbox1.items.add(ProcessDirectory(Combobox1.SelectedItem.Text));


Uhm, hope you got all that.. not sure if it''l help much but hopefully get you on the right direction..


此链接的示例较大,但是因为您希望在搜索过程中支持停止",所以需要使用线程.否则,UI将不会响应,用户将不得不等待操作完成.

此后台线程示例显示了如何使用文件搜索作为任务来实现这一点.这只是您想要完成的任务,因此非常适合.

http://msdn.microsoft.com/en-us/library/3s8xdz5c [ ^ ]

祝你好运!
This link has an example that is somewhat bigger, but because you could like to support "stop" during the search you would need to use a thread. Otherwise the UI won''t be responsive and the user would have to wait until the operation is completed.

This example on background threads shows how to implement this, using a file search as task. This is just the task you would like to have, so it''s a perfect match.

http://msdn.microsoft.com/en-us/library/3s8xdz5c[^]

Good luck!


这篇关于请我在边缘帮助!!!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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