locked
Rename Document in project RRS feed

  • Question

  • I tried to rename a document in a project with the following two `IVsRunningDocumentTable::RenameDocument` and `VsShellUtillities::RenameDocument`, however both of them just created a new file with the new content, but the old file didn't got removed?

    IVsRunningDocumentTable::RenameDocument(fullName, newFullName, VSConstants.HIERARCHY_DONTCHANGE, VSConstants.VSITEMID_NIL);

    The other one got invoked quite similar. Is there any alternative to that or is there anything wrong with the current code?


    • Edited by 24_minutes Saturday, March 21, 2020 2:22 AM
    Saturday, March 21, 2020 2:21 AM

All replies

  • Hi 24_minutes,

    Sorry for delay in reply.

    You could try to tag specified document is unlocked, please refer here:

    IVsRunningDocumentTable docTable = site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
    
    docTable.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldName, out pIVsHierarchy, out itemId, out docData, out uiVsDocCookie);
    
    docTable.RenameDocument(oldName, newName, pHier, newItemId)

    Hope it could help you.

    Best Regards,

    Dylan

    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. 

    Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Monday, March 23, 2020 6:50 AM
  • I already tried that exactly, but with the same result.
    Tuesday, March 24, 2020 1:26 AM
  • Hi 24_minutes,

    Thanks for your reply.

    Maybe you can manually remove old file and then reload your project.

    Besides, we also recommend you could go to Help-> Send a feedback -> Report a Problem in VS IDE, and report it to product team.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, March 26, 2020 9:19 AM