Load() public method

public Load ( string path ) : string
path string
return string
示例#1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dataDirectory"></param>
        /// <param name="outputDirectory"></param>
        public void PostProcess(string dataDirectory, 
                                string outputDirectory)
        {
            CsvConfiguration csvConfiguration = new CsvConfiguration();
            csvConfiguration.QuoteAllFields = true;

            using (FileStream fileStream = new FileStream(System.IO.Path.Combine(outputDirectory, "Attachment.Hashes.csv"), FileMode.Append, FileAccess.Write, FileShare.Read))
            using (StreamWriter streamWriter = new StreamWriter(fileStream))
            using (CsvHelper.CsvWriter csvWriter = new CsvHelper.CsvWriter(streamWriter, csvConfiguration))
            {
                // Now MD5 the files
                foreach (string file in System.IO.Directory.EnumerateFiles(outputDirectory,
                                                                           "*.xml",
                                                                           SearchOption.AllDirectories))
                {
                    string fileName = System.IO.Path.GetFileName(file);
                    if (fileName.StartsWith("Message.Details.") == false)
                    {
                        continue;
                    }

                    MessageDetails messageDetails = new MessageDetails();
                    string ret = messageDetails.Load(file);
                    if (ret.Length == 0)
                    {
                        foreach (AttachmentDetails attachment in messageDetails.Attachments)
                        {
                            csvWriter.WriteField(attachment.Md5);
                            csvWriter.WriteField(attachment.File);
                            csvWriter.WriteField(messageDetails.SrcIp);
                            csvWriter.WriteField(messageDetails.SrcPort);
                            csvWriter.WriteField(messageDetails.DstIp);
                            csvWriter.WriteField(messageDetails.DstPort);
                            csvWriter.WriteField(messageDetails.To);
                            csvWriter.WriteField(messageDetails.From);
                            csvWriter.WriteField(messageDetails.MailFrom);
                            csvWriter.WriteField(messageDetails.Sender);
                            csvWriter.WriteField(messageDetails.Subject);
                            csvWriter.WriteField(messageDetails.Date);
                            csvWriter.NextRecord();
                        }
                    }
                }
            }

            ProcessAttachmentHashes(outputDirectory);
        }