private void OnButtonClick_FileNumber(object sender, System.EventArgs e) { string filename = new string(' ', MAX_PATH); MccDaq.ErrorInfo errorInfo; int FileNumber; bool ValidNum; ValidNum = int.TryParse(this.txtFileNum.Text, out FileNumber); lblComment.Text = "Get file number " + FileNumber.ToString() + " from directory " + m_Path; // Get the Nth file in the directory // Parameters: // m_FileNumber :Nth file in the directory // m_Path :path to search // filename :receives name of file errorInfo = MccDaq.DataLogger.GetFileName (FileNumber, ref m_Path, ref filename); if (errorInfo.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors) { lblComment.Text = errorInfo.Message; } else { lbFileList.Items.Clear(); filename = filename.Trim(); string newpath = filename.Trim('\0'); string absolutePath = Path.GetFullPath(newpath); lbFileList.Items.Add(absolutePath); } }
/// <summary> /// Получить имя файла соответствующее конкретному типу сообщения /// </summary> /// <returns>имя файла</returns> public virtual string GetFileName() { string res = string.Format("SP.{0:00}.{1}{2}.{3}{4}.txt", LogicalHLR, CreationDate.ToString("yyyyMMdd"), CreationDate.ToString("HHmmss"), (int)Initiator, FileNumber.ToString().PadLeft(13, '0')); return(res); }
private void WriteToFile() { var filePath = $"{FileDirectory}\\{FileName}_{FileNumber.ToString("D2")}.{FileExtension}"; WriteLineFile(filePath); FileLines += BuilderLines; BuilderLines = 0; if (FileLines > FileThreshold) { FileLines = 0; FileNumber++; ConcatNewLine(FileHeader); } }
public BinaryReader OpenEntryFile(string installDir) { var rdbPath = Path.Combine(installDir, "RDB"); var rdbFile = Path.Combine(rdbPath, FileNumber.ToString("00")); rdbFile = Path.ChangeExtension(rdbFile, ".rdbdata"); var reader = new BinaryReader(File.Open(rdbFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); reader.BaseStream.Seek(FileOffset - 16, SeekOrigin.Begin); if (reader.ReadInt32() != Type) { throw new Exception("Error opening RDB File. Type Mismatch."); } if (reader.ReadInt32() != Id) { throw new Exception("Error opening RDB File. ID Mismatch."); } if (reader.ReadInt32() != (_rawFileLength ?? FileLength)) { throw new Exception("Error opening RDB File. Length Mismatch."); } var e = reader.ReadInt32(); //Not sure what this is //Some file types have an additional 12-byte header injected into the file data, which starts with the RDB Type. Check for that and skip if needed. var type = reader.ReadInt32(); if (type == Type) { if (!_rawFileLength.HasValue) { //Keep track of the raw file length, the public length should match the actual readable stream length for consumers of the stream. _rawFileLength = FileLength; FileLength = _rawFileLength.Value - 12; } reader.BaseStream.Seek(8, SeekOrigin.Current); } else { reader.BaseStream.Seek(-4, SeekOrigin.Current); } return(reader); }