public IEnumerable <DtaFile> Split(int numberOfSpectra = 5000) { SplitedDtaFiles = new List <DtaFile>(); int fileCount = 1; string tempPath = Path.GetTempPath(); string tempName = Path.Combine(tempPath, Name + "_" + fileCount + ".txt"); StreamWriter writer = new StreamWriter(tempName); DtaFile dtaFile = null; int dtaCount = 0; using (StreamReader reader = new StreamReader(FilePath)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line.StartsWith("<dta")) { dtaCount++; if (dtaCount > numberOfSpectra) { dtaCount = 0; writer.Close(); dtaFile = new DtaFile(tempName) { ParameterLine = ParameterLine, UserModFile = UserModFile }; SplitedDtaFiles.Add(dtaFile); yield return(dtaFile); fileCount++; tempName = Path.Combine(tempPath, Name + "_" + fileCount + ".txt"); writer = new StreamWriter(tempName); } } writer.WriteLine(line); } } writer.Close(); dtaFile = new DtaFile(tempName) { ParameterLine = ParameterLine, UserModFile = UserModFile }; SplitedDtaFiles.Add(dtaFile); yield return(dtaFile); }
public IEnumerable<DtaFile> Split(int numberOfSpectra = 5000) { SplitedDtaFiles = new List<DtaFile>(); int fileCount = 1; string tempPath = Path.GetTempPath(); string tempName = Path.Combine(tempPath, Name + "_" + fileCount + ".txt"); StreamWriter writer = new StreamWriter(tempName); DtaFile dtaFile = null; int dtaCount = 0; using (StreamReader reader = new StreamReader(FilePath)) { while(!reader.EndOfStream) { string line = reader.ReadLine(); if (line.StartsWith("<dta")) { dtaCount++; if (dtaCount > numberOfSpectra) { dtaCount = 0; writer.Close(); dtaFile = new DtaFile(tempName) { ParameterLine = ParameterLine, UserModFile = UserModFile }; SplitedDtaFiles.Add(dtaFile); yield return dtaFile; fileCount++; tempName = Path.Combine(tempPath, Name + "_" + fileCount + ".txt"); writer = new StreamWriter(tempName); } } writer.WriteLine(line); } } writer.Close(); dtaFile = new DtaFile(tempName) { ParameterLine = ParameterLine, UserModFile = UserModFile }; SplitedDtaFiles.Add(dtaFile); yield return dtaFile; }
private void AddDtaFile(string filePath) { DtaFile file = new DtaFile(filePath); DtaFiles.Add(file); }