A
Alan Roberts
In VB6 I could use random access and fixed record lengths to read specific
records from a test file. Eg the following code would save a LogEntry to a
file at the location specified by RecordNumber.
Private Type LogEntry
Date As String * 20
Number As String * 20
Source As String * 100
Description As String * 100
CRLF As String * 2
End Type
Public Sub RecordError(Num As Long, Source As String, Desc As String)
Dim FF As Integer
Dim CurrentRecord As LogEntry
'set the record values
With CurrentRecord
.Date = Trim(Format$(Now, "DD/MM/YYYY HH:MM:SS"))
.Number = Num
.Source = Trim(Source)
.Description = Trim(Desc)
.CRLF = vbCrLf
End With
'save the record
FF = FreeFile
Open "file.txt" For Random As FF Len = 242
Put FF, RecordNumber, CurrentRecord
Close #FF
End Sub
How do I do this sort of thing in Csharp? I can't seem to find a way to
read/write fixed sized records.
Thanks
Alan
records from a test file. Eg the following code would save a LogEntry to a
file at the location specified by RecordNumber.
Private Type LogEntry
Date As String * 20
Number As String * 20
Source As String * 100
Description As String * 100
CRLF As String * 2
End Type
Public Sub RecordError(Num As Long, Source As String, Desc As String)
Dim FF As Integer
Dim CurrentRecord As LogEntry
'set the record values
With CurrentRecord
.Date = Trim(Format$(Now, "DD/MM/YYYY HH:MM:SS"))
.Number = Num
.Source = Trim(Source)
.Description = Trim(Desc)
.CRLF = vbCrLf
End With
'save the record
FF = FreeFile
Open "file.txt" For Random As FF Len = 242
Put FF, RecordNumber, CurrentRecord
Close #FF
End Sub
How do I do this sort of thing in Csharp? I can't seem to find a way to
read/write fixed sized records.
Thanks
Alan