txtfile

Status
Niet open voor verdere reacties.

bonnowagt

Gebruiker
Lid geworden
7 dec 2006
Berichten
445
Ik plaats vanuit mijn listview gegevens in een textfile (data.txt). Nu stopt de opslag bij ongeveer 1MB. Komt dit omdat een txt6file niet meer kan opslaan of ligt dit aan iets anders. Mocht dit het eerste zijn hoe zou ik dan de gevens het beste op kunnen slaan
 
Volgens mij is er niet echt een 'datalimiet' of zoiets.

Kun je je code even posten? Wellicht ligt het daaraan.
 
Code:
Public Class Form1
    Private myCoolFile As String = "C:\dvd\dvd.txt"
    Private Sub DVDCDBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DVDCDBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.DVDCDBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.MijndatabaseDataSet)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'MijndatabaseDataSet.DVDCD' table. You can move, or remove it, as needed.
        Me.DVDCDTableAdapter.Fill(Me.MijndatabaseDataSet.DVDCD)
        If IO.File.Exists(myCoolFile) Then '// check if file exists.
            Dim myCoolFileLines() As String = IO.File.ReadAllLines(myCoolFile) '// load your file as a string array.
            For Each line As String In myCoolFileLines '// loop thru array list.
                Dim lineArray() As String = line.Split("#") '// separate by "#" character.
                Dim newItem As New ListViewItem(lineArray(0))
                Try
                    newItem.SubItems.Add(lineArray(1))
                    newItem.SubItems.Add(lineArray(2))
                    newItem.SubItems.Add(lineArray(3))
                    newItem.SubItems.Add(lineArray(4))
                    newItem.SubItems.Add(lineArray(5))
                    newItem.SubItems.Add(lineArray(6))
                    newItem.SubItems.Add(lineArray(7))
                    newItem.SubItems.Add(lineArray(8))
                    newItem.SubItems.Add(lineArray(9))

                    ListView1.Items.Add(newItem)
                Catch ex As Exception
                End Try
            Next
        End If
        Me.Label1.Text = ListView1.Items.Count
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim itm As ListViewItem
        Dim str(18) As String
        str(0) = TitelTextBox.Text
        str(1) = NummerTextBox.Text
        str(2) = OpnamedragerComboBox.Text
        str(3) = BijzonderhedenTextBox.Text
        str(4) = SubcategorieComboBox.Text
        str(5) = KofferComboBox.Text
        str(6) = LandComboBox.Text
        str(7) = JaarComboBox.Text

        str(8) = RatingComboBox.Text

        itm = New ListViewItem(str)
        ListView1.Items.Add(itm)
        Dim myWriter As New IO.StreamWriter(myCoolFile)
        For Each myItem As ListViewItem In ListView1.Items
            myWriter.WriteLine(myItem.Text & "#" & myItem.SubItems(1).Text & "#" & myItem.SubItems(2).Text _
                     & "#" & myItem.SubItems(3).Text & "#" & myItem.SubItems(4).Text & "#" & myItem.SubItems(5).Text _
                       & "#" & myItem.SubItems(6).Text & "#" & myItem.SubItems(7).Text & "#" & myItem.SubItems(8).Text _
          & "#" & myItem.SubItems(9).Text)
        Next
        myWriter.Close()

        Me.DVDCDBindingSource.MoveNext()

        '    ListView1.Items(0).Selected = True : ListView1.Select()


        MsgBox("Record opgeslagen")
        Me.Label1.Text = ListView1.Items.Count
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        Try
            TitelTextBox.Text = ListView1.SelectedItems.Item(0).Text
            NummerTextBox.Text = ListView1.SelectedItems.Item(0).SubItems(1).Text
            OpnamedragerComboBox.Text = ListView1.SelectedItems.Item(0).SubItems(2).Text
            BijzonderhedenTextBox.Text = ListView1.SelectedItems.Item(0).SubItems(3).Text
            SubcategorieComboBox.Text = ListView1.SelectedItems.Item(0).SubItems(4).Text
            KofferComboBox.Text = ListView1.SelectedItems.Item(0).SubItems(5).Text
            LandComboBox.Text = ListView1.SelectedItems.Item(0).SubItems(6).Text
            JaarComboBox.Text = ListView1.SelectedItems.Item(0).SubItems(7).Text
            RatingComboBox.Text = ListView1.SelectedItems.Item(0).SubItems(8).Text
        Catch ex As Exception
        End Try
    End Sub
 
End Class

Ik heb een database met 1600 records. Ik wil deze in mijn listview invoeren en nie tin een datagrid. Ik voer via een knop de records in de listview, maar deze stopt bij zon 1mb en mist onderweg ook records.
 
Wat staat er dan in het tekstbestand? Missen er gewoon records? Of staat er dan dit: ######## ?

Als ik mijn computer 1600 x laat schrijven, werkt het wel gewoon.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan