I want to write data in a file frequently ,
I wonder if I call CreateFile() each time I write it,
Does this way cost so much than the way that I just call it once ,then
use the handle many times?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are going to write to the file several times, it would be better to keep the handle returned by CreateFile(). Creating a kernel handle to a file will always be more inefficient that reusing the old handle (all other things being equal), but there may be other considerations to take into account. As always, you should measure the performance before and after you do any such optimizations.