Hi, I am doing "Virus Tracking System" Project. I have to scan the directory selected from treeview
scan directory selected from treeview control
Collapse
X
-
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
-
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.
-FrinnyLast edited by Frinavale; Jan 21 '15, 09:59 PM.Comment
-
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
Comment