how do you check if a file ( a.txt ) is being used by another process?Code:int main(int argc,char *argv[])
{
if ( no Being used by another process )
remove("a.txt");
return 0;
}
thanks.
how do you check if a file ( a.txt ) is being used by another process?Code:int main(int argc,char *argv[])
{
if ( no Being used by another process )
remove("a.txt");
return 0;
}
thanks.
It depends on your OS.
use lsof ./a.txt. This will show you not only how many processes of a file open but who they are. Hint: this also works on sockets too ;)
Don't ask me; I only code for Windows if there is a gun pointing at my head...all kidding aside there are a lot of Redmond-ites here that I am sure would be happy to tell you..cool thing about NIX though is you can get the source code to lsof and code it right into your app :D