Inheritance: System.IO.File
示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
 private void AddDtaFile(string filePath)
 {
     DtaFile file = new DtaFile(filePath);
     DtaFiles.Add(file);
 }
示例#4
0
        private void AddDtaFile(string filePath)
        {
            DtaFile file = new DtaFile(filePath);

            DtaFiles.Add(file);
        }