scan directory selected from treeview control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kiruthi
    New Member
    • Jan 2015
    • 5

    scan directory selected from treeview control

    Hi, I am doing "Virus Tracking System" Project. I have to scan the directory selected from treeview
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Ok? "Scan"? What does "Scan" entail?

    What have you tried so far?

    What are you having problems with?
    Getting the selected item?

    -Frinny

    Comment

    • kiruthi
      New Member
      • Jan 2015
      • 5

      #3
      Actually, I stored certain words related to virus in notepad. And then i am using apriori algorithm to find the number of occurrence of the words. And then i scan the single text file to determine whether that file have those words or not. Now i have to scan the directory selected from the treeview control? please help me.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        How did you populate your TreeView?

        You needed to use the DirectoryInfo Class to get the listing of the directories right?

        I'm assuming that the selected value of your TreeView will contain the path to the directory that you want to loop through....

        You need to use the DirectoryInfo class again and use the GetFiles Method to retrieve a list of the files in that directory.

        Then you need to loop through those files, determine if the file is valid for your "scanning process"... read the contents of the file and determine if it contains any of the words that you are looking for.


        Take a look at the two links that I posted because they contain information and examples on how to use them.
        -Frinny
        Last edited by Frinavale; Jan 21 '15, 09:59 PM.

        Comment

        • kiruthi
          New Member
          • Jan 2015
          • 5

          #5
          Thank you. But i have to implement it in windows application. I tried your code in windows application. But it shows some error. So can u please convert it into windows application.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            It would be really helpful if you posted the error message and the line that is causing the error so that we can help you.

            Comment

            • kiruthi
              New Member
              • Jan 2015
              • 5

              #7
              I don't want to copy the files one directory to another directory. I want to scan the directory.

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Kiruthi,

                Those examples are examples of how to use the methods to read directories.

                You do not need to use the copy functionality.


                -Frinny

                Comment

                • kiruthi
                  New Member
                  • Jan 2015
                  • 5

                  #9
                  when the progress bar is start the timer is start with value then progress bar is stopped the process the timer is stop and total time is displayed in label box.what is the code for c#..

                  Comment

                  • Arunmozhi
                    New Member
                    • Mar 2015
                    • 4

                    #10
                    Code:
                    List<string> AllFiles = new List<string>();
                                    string[] filePaths = Directory.GetDirectories(@"C:\Documents and Settings\arunmozhi\My Documents\Downloads\AIRLINE DATA COLLECTIONSS\");
                    
                                    foreach (string fileName in filePaths)
                                    {
                                        String[] FileNames = Directory.GetFiles(fileName);//Get All file names from each folder
                    
                                        foreach (string textfiles in FileNames)
                                        {
                                            string[] lines = System.IO.File.ReadAllLines(textfiles);//Read all text from each files
                    
                                            for (int startline = 0; startline < lines.Length; startline++)
                                           {
                    //do your codes//
                    }
                    }
                    }
                    Last edited by Rabbit; Mar 24 '15, 04:01 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.

                    Comment

                    Working...