private int ScanAFile(string filePath) { //dumpbin file FilePresentation filePresentation = new FilePresentation(); filePresentation.ExecuteCommandAFile(filePath, temp_stored_path); string[] filepats = Directory.GetFiles(temp_stored_path); //vector hoa double[] featureVector = filePresentation.VectorizeAFile(Directory.GetFiles(System.IO.Path.Combine(Environment.CurrentDirectory, temp_stored_path))[0]); //chuan hoa double[] basic_features = featureVector.Take(Globals.BASIC_FEATURES).ToArray(); double[] dlls = new double[featureVector.Length - Globals.BASIC_FEATURES]; for (int i = 0; i < dlls.Length; i++) { dlls[i] = featureVector[Globals.BASIC_FEATURES + i]; } VDSElement e = new VDSElement(Globals.DETECTOR_RADIUS, new DLLSignature(basic_features, dlls)); List <VDSElement> testing_data = new List <VDSElement>(); testing_data.Add(e); //kiem tra int[] predictingLabels = algorithm.Learner.PredictLabel(algorithm.ConvertToDataLearnerForPredictLabel(testing_data)); //Xoa cac file temp File.Delete(Directory.GetFiles(temp_stored_path)[0]); return(predictingLabels[0]);//1: virus, 0: benign --> 0 la virus, 1 benign }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { //string[] trainingSetPath = Directory.GetDirectories(trainingFolderDialog.SelectedPath); //foreach (var aTrainingSetPath in trainingSetPath) //{ // FilePresentation filePresentation = new FilePresentation(aTrainingSetPath); // filePresentation.PresentFiles(); //} string aTrainingSetPath = txtTrainingFolder.Text; FilePresentation filePresentation = new FilePresentation(aTrainingSetPath); filePresentation.PresentFiles(worker.ReportProgress); }