qq_30983437
筱红包
采纳率0%
2015-12-08 11:36

vb Get #lngFno, 101, datLogdat 改写成c#,怎么改?

10

下面一段VB代码改写成C#,该怎么改?
Public Type TYPE_SYSLOG
lngPointer As Long

strDate As String
strTime As String
lngStatus As Long

lngSize As Long

strLog As String
End Type

Public Sub PubSuSysbLogPut(prmstrLog As String, prmlngStatus As Long)
Dim lngFno As Long

Dim lngPointer As Long

Dim VarNowTime As Variant

Dim datLogdat As TYPE_SYSLOG

Dim lngFsize As Long

Dim lngCnt As Long

Dim prmstrFname As String

prmstrFname="D:\log.SLG"

On Error Resume Next
lngFsize = FileLen(prmstrFname)
If Err Then
    FileCopy NEW_SYSLOG, prmstrFname
End If
On Error GoTo 0

VarNowTime = Now

On Error Resume Next
For lngCnt = 1 To 200
    Err = 0
    lngFno = FreeFile
    Open prmstrFname For Random Lock Write As #lngFno Len = Len(datLogdat)
    If Err Then
        Call Sleep(100)
    Else
        Exit For
    End If
Next lngCnt

If lngCnt > 200 Then
    If SYS_GRVL_ErrHandler_Dlog_Sw = SYS_GRVL_EHDLOG_ON Then
        MsgBox "Write Error" & Chr(&HD) & "FileName = " & prmstrFname & Chr(&HD) & "ErrorCode = " & Err
    End If
End If
On Error GoTo 0

Get #lngFno, 101, datLogdat

lngPointer = datLogdat.lngPointer + 1
If lngPointer > 100 Then lngPointer = lngPointer - 100

With datLogdat
    .lngPointer = lngPointer
    .strDate = Format(VarNowTime, "yyyy/mm/dd")
    .strTime = Format(VarNowTime, "hh:nn:ss")
    .lngStatus = prmlngStatus
    .lngSize = LenB(StrConv(prmstrLog, vbFromUnicode))
    .strLog = prmstrLog
End With

Put #lngFno, datLogdat.lngPointer, datLogdat

Put #lngFno, 1011, datLogdat

Close #lngFno

End Sub

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐