我把文件按行取出,放在一个结构体数组中,然后通过结构体的某一项和已知条件进行比较,满足条件则把该行从文件中删除,问如何实现?

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3360/3360896.xml?temp=.5140345
      

  2.   

    Private Sub DelFileRow(fileApp As String, DelRow As Long)
    Dim a() As String
    Dim S As String
    Dim I As Long, II As LongOpen fileApp For Input As #1
    S = StrConv(InputB(LOF(1), #1), vbUnicode)
    Close #1a = Split(S, vbCrLf)
    II = UBound(a, 1)S = ""
    For I = 0 To II
        If I <> DelRow Then
            S = S & a(I) & vbCrLf
        End If
    Next IOpen fileApp For Output As #1
    Print #1, Trim(S)
    Debug.Print S
    Close #1
    End SubPrivate Sub Command1_Click()
    DelFileRow "F:\readme.txt", 8'删除第8行
    MsgBox "ok"
    End Sub