Display a message before deleting/renaming a file.

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

  1. macrumors newbie

    Joined:
    Jul 2, 2006
    #1
    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. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #2
    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. macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #3
    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. thread starter macrumors newbie

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

Share This Page