views:

31

answers:

0

Hello. Method strongly promoted as an alternative to the deprecated methods MSDN writing files this clever, that's just scary:). He not only writes and appends the contents of the file, but also penetrates the written. For example, create the following code:

 Dim fl As IO.StreamReader = My.Computer.FileSystem.OpenTextFileReader("C:\src.txt", System.Text.Encoding.GetEncoding(1251))
Do While Not fl.EndOfStream
  My.Computer.FileSystem.WriteAllText("C:\tst.txt", fl.ReadLine & vbCrLf, True, System.Text.Encoding.GetEncoding(1251))
Loop

Then take the above file C:\src.txt about dozens or hundreds of kilobytes of plain text and check it our code. Results for 33 KB text - 3 to 4 seconds, 120 KB letters-13-14 sec.

Now, somewhere in the first lines of text, type the following sequence-Enter (that is, a new string, required), then there can be multiple spaces, and you can immediately at the beginning of the string are two or more slash "//". And again, let us try to rewrite this miracle method.

Results with "//": 33 KB-13 sec, 120 KB-2 min. 43 sec. To deal with so much time? Experience held multiple times and always occur. With a single slash or with other combinations of characters such tricks are not identified. Even reverse "\" behave well. Does anyone know about this trick?