View Single Post
  #2 (permalink)  
Old May 20th, 2013, 11:16 AM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts

Sorry for the long delay. I didn't see this post.

There is only one problem left that stumps me. As long as I close out the application completely before I open a file there is no problem. However, it seems to me that I should be able to work with a file, close the file and open it again without closing the entire application. Just like in Microsoft Word, you can open a file or start a new one, edit it, and close the file without leaving MicroSoft Word.

I assume that even though I clear all of the Text Boxes, TreeView Box, List Boxes and so on, so that everything looks like it did before I opened the file, there must be something in the code that is not going back to its previous state. Otherwise, why do I get a different result when I open a file immediately after starting the application than I do when I open a file after saving it and without leaving the application?
How is the file different?

If you write into a file, the text may not actually be written to the disk right away. Instead the system may buffer the data and then write it later when the buffer is full. This is more efficient than writing the data immediately because that would force the program to wait for the relatively slow disk drive.

All this means if the program crashes or exits without flushing or closing the file, some of the data you wanted to write into it may be lost.

So the program should always close the file before exiting.

If you close and reopen the file, it should look the same as if the program had closed and then restarted.

I hope that help. Sorry again for the long delay.

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)