The above line will read the whole file at once. if the file is big it may lead to memory problem, I prefer to read line by line, I guess my code will be faster on PII with 64mb ram.
If you deal with small files (a few tens or hundreds of KBs) or you need to keep the whole file in the memory anyway, using My namespace is very handy requiring only a few lines of code. Besides, My namespace does have quite a few other handy classes too, not just My.Computer.FileSystem. If you don't need to keep the whole file in the memory or the file is really large, System.IO is absolutely the better solution. What comes to the speed of the code, with modern processor there's hardly any practically significant difference.
And after all, it's a question about selecting the right "tool"
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Offline 1,024 posts
since Aug 2008