Closing opened file handles

  • Thread starter Thread starter Neville Lang
  • Start date Start date
N

Neville Lang

Hi all,

I have a .NET CF app that calls some functions in a third party DLL
associated with my app. One of the function calls opens a data file and
keeps it open for the session.

When my app is running, I have provided a feature that enables a user to
move some large data files to a memory card but not the current executing
EXE file - it will remain in RAM. One of the data files is this third party
data file.

I have noticed that after I copy the third party data file to a memory card
in this session of my app, I cannot delete it from its original location due
to its opened file handle. Once this file handle is opened by the third
party app, it is kept open until the end of my app's session, and then it is
closed. My app normally closes if the user taps on the "ok" button - I do
not keep it running.

Is ii possible for me to access and close this file handle within my app so
that I am able to delete the data file from its original location? If so,
how might I go about this.

I must point out that the third party software will continue to operate when
this file handle is closed - the data file is just re-opened later if it has
been closed.

Regards,
Neville Lang
 
Hi,
I'll assume the third party .dll has no API to retrieve the file handle
or close the file programmatically. At the end of the session though how
does it know to close the file? If there is an API that closes down the
session with the 3rd party .dll you might do that and then re-open a new
session once the file has moved. If the .dll closes its file handle upon
being unloaded you might try letting the .dll unload and then reload it
after moving the file. Perhaps one of those options helps?
-Noah Falk, Microsoft .NET CF
 
Noah,

Thank you for your response. I will have a look at those options.

Regards,
Neville Lang
 
Back
Top