I did help before this code, though I have stumbled one, and I'm not sure the correct path. I have the code below which searches and replaces the search and place of more than 120 km. The problem is that the text file is very easy on 5 gig of large files, so I'm not surprised if there is a memory problem, so I have to load the data in the block, if that is possible? CmdBtnTestReplace
Personal Sub CmdBtnTestReplace_Click (as System.Object, E. System.EventArgs). String = "C: \ Backup \ log \ master.txt" Give the file name: "New System.IO.StreamWriter (wrtFile) is rendered as the string s = strRead.ReadToEnd () 'to find Runs through more than 120K and changes each row to DataGridViewRow as in the DataGridView1.Rows so as not to row.IsNewRow then retype Find1 string = Row as .seals (0) Value. Toasting Deam Reptens 1 String = In the form of a queue. Seals (1). Value String cursor. Current = cursor. Waiting quasars use strings from column 1 and varies with string from second column. S = s.Replace (Find1, Replace1) end then next strWrite.Write strread.Close () StrWrite.Close () Cursor.Current = Cursors.Default MessageBox.Show ("Finished instead of") End Sub
Once loaded in memory is too large, and lost H string is never going to span multiple lines, then reading only one row at a time would be the simplest solution, for example:
string = "c: \" as a dim fName New System.IO.StreamReader (fName) dim strWrite like New System.IO.StreamWriter (wrtFile), as "slow \" in the form of a slow wrtFile string = "c: \ backup \ logs \ masterUserFormatted.txt" As Cursor.Current = Cursors.WaitCursor While this is true it is not true then the line line string = strRead.ReadLine () is nothing so isnot then each row For DataGridViewRow as in DataGridView1.Rows, then not row.IsNewRow then find the string as string = row.Cells (0) .Value.ToString dim Replace1 as string = row.Cells (1) .Value. ToString line = Replace line = Replace (Find1, Replace1) next strWrite.WriteLine (line) or else exit while end if end while strRead.Close () strWrite.Close () Cursor.Current = Cursors.Default MessageBox.Show ( "Finished instead of")
It is worth mentioning that StreamReader and StreamReader
apply IDispo sable
. As such, instead of calling it explicitly, close
>
Comments
Post a Comment