0

I need to find a way how to look into files that are not loaded into any component or stringlist in my program. Is it possible to work lets say like copy(somefile.html, 1, 100)? I have a file of messages from facebook and I want to do program that can for example count how many msgs I have with some person but this kind of thing I can do on my own, my only problem is to find a way how to work with this file. It will probably be stringlist? but I am not sure.

hix
  • 45
  • 1
  • 10
sexyjohny
  • 21
  • 4
  • No, you must load the file content into memory before you can then work with it. Look at `TStringList.LoadFromFile()`, `TMemoryStream.LoadFromFile()`, `System.IOUtils.TFile.ReadAllBytes()`, etc. Or use a memory mapping via `CreateFile()`/`CreateFileMapping()`/`MapViewOfFile()`. – Remy Lebeau May 03 '17 at 20:24
  • Why? Is this an xy question, you have a problem x and think that y will solve it, but you don't know how to do y. – Tom Brunberg May 03 '17 at 20:26
  • I dunno if there's other way to do it. You can use `WebBrowser` or the other examples like @RemyLebeau said. – William May 03 '17 at 20:33
  • @Remy: or load *parts* into memory, e.g. line by line or buffer by buffer. It does not have to be the entire file content at once. – Rudy Velthuis May 03 '17 at 21:09
  • I've read your edited question, but I still don't understand why you do not want to load the file into your own program. Are you afraid that you might destroy the file or what is it? – Tom Brunberg May 03 '17 at 21:49
  • Because the file is to big and every component lags the program when I try to load the data. – sexyjohny May 03 '17 at 22:14
  • then try buffered reading, there is some good questions about that in here – Nasreddine Galfout May 03 '17 at 22:25
  • Facebook has API, use that (do not download the content and process it by yourself, it's an extra work). To your specific question as I interpret it (_How to process HTML file (possibly just the Facebook message list)?_), look for HTML parser. But definitely prefer the FB API if it's FB specific stuff. – Victoria May 23 '17 at 09:20

0 Answers0