I have some doubts for what you told me to do...can you please give some informtion on these things...
In my application if i am receiving data 10 times & i'm transmitting data 10 times then every time i have to open & close the file or no need of opening the file evrey time.
Only on the application exit i have to close the file...
Since i'll recieve & transmit large data wont it be a problem if everytime i have to open & close the file... & what if my file size becomes too large if i received very learge data which i logged in that Log file...
in this case, the BEST thing you can do is write it to a string then at the end of your app, write it to the file. It will also be less expensive.
so globally, make a StringBuilder variable:
System.Text.StringBuilder theLogEntry = new System.Text.StringBuilder();
then whenever you are going to be writing to it from the same class:
on your application exit event or form_closing event, write the entire contents to disk:
System.IO.StreamWriter theWriter = new System.IO.StreamWriter("path\file.txt");
and thats it. during runtime you will be appending your inputs/outputs to the string, declared globally. this will store your log