Display a message before deleting/renaming a file.

Discussion in 'Mac Programming' started by ithil, Jul 10, 2006.

  1. ithil macrumors newbie

    Jul 2, 2006
    Hi all,

    If I try to delete ( by emptying trash) a XCode project, when it is open, it will display a message [The operation cannot be complete because the item "main.m" is in use] & trash is not emptied.

    I want to display a similar error message if my application is trying to delete/rename a file, which is used by other application. Is there a way to provide such a behaviour?

    Thanks... :)
  2. slooksterPSV macrumors 68040


    Apr 17, 2004
    Now, someone correct me if I'm wrong, but when you open a stream to a file it registers as being open, now it is possible to test whether there is a stream going into or out of that file based on its location? ID? something? There are many programs that do this, so it is possible - you may want to search for file isopen command or something.
  3. savar macrumors 68000


    Jun 6, 2003
    District of Columbia
    You can't delete a file that is open for writing. That's why the trash gives you that message.

    If you want your app to give the same message, open the file for writing.
  4. ithil thread starter macrumors newbie

    Jul 2, 2006
    I guess i could have done that..:) thanks for your time..

Share This Page