Move or Delete prompts Windows Message

  1. 2 months ago

    When I use FolderItem.Remove or FolderItem.Delete on bulk file processes, sometimes Windows pops up a message that is not handled by XOJO.

    The Windows message reads:

    The item <Filename> that this shortcut refers to has been changed or moved, so this shortcut will no longer work properly.

    Nearest match on based on size, date, and type: ...

    Do you want to fix this shortcut to point to this target or do you just want to delete it?

    It stops the XOJO program until the user selects an option, which is a problem because I want it to run unattended.

    How do I prevent this window from popping up?

    Use FolderItem.TrueItem or FolderItem.TrueChild (instead of FolderItem.Item or FolderItem.Child) to get a FolderItem that points to the shortcut file itself rather that the shortcut target.

    Dim root As FolderItem = GetFolderItem("C:\Foo\bar") ' parent of the file to delete
    
    Dim item As FolderItem = root.TrueItem(0) ' first item in the directory
    // OR
    Dim item As FolderItem = root.TrueChild("filename.txt") ' get child by name
    
    item.Delete()
  2. I should add this is my first posting in the XOJO forum. Thanks in advance for any assistance.

  3. Andrew L

    Jun 12 Answer San Francisco, CA, USA

    Use FolderItem.TrueItem or FolderItem.TrueChild (instead of FolderItem.Item or FolderItem.Child) to get a FolderItem that points to the shortcut file itself rather that the shortcut target.

    Dim root As FolderItem = GetFolderItem("C:\Foo\bar") ' parent of the file to delete
    
    Dim item As FolderItem = root.TrueItem(0) ' first item in the directory
    // OR
    Dim item As FolderItem = root.TrueChild("filename.txt") ' get child by name
    
    item.Delete()
  4. Andrew - I just looked up FolderItem.TrueItem.

    Very helpful - Thank you for your prompt reply.

    Alex

  5. I used GetTrueFolderItem - that worked.

or Sign Up to reply!