locked
How do i know whether a file is renamed... RRS feed

  • Question

  • Hi,

    How do i know whether a file is renamed. I am using custom sync provider for sync with a remote drive. i can know which files are modified but i want to know whether any file is renamed. 

    Is there any way where i can know that a file has been renamed from its properties....

    Pankaj Bajpai. Prosares Solutions ASP.Net | Sharepoint | Consulting SharePoint | ASP.Net | Business Intelligence http://www.prosares.com http://www.linkedin.com/in/pankajbbajpai
    • Moved by Max Wang_1983 Thursday, April 21, 2011 12:33 AM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Wednesday, September 30, 2009 4:29 PM

Answers

  • Are you syncing with the FileSyncProvider?  If so, in the update call on your provider you should be able to check the filename by looking at the Name property on the FileData object that you grab from your IFileDataRetriever and compare that to what you currently have. 

    Like this:

    IFileDataRetriever fileData = (IFileDataRetriever)itemData;
    string newFileName= fileData.FileData.Name;

     // oldFileName is the value of your current filename
    if (newFileName != oldFileName)
    {
      // Rename
    }

    In fact, you should be checking the entire relative path of the files to detect moves (if you are doing a heirarchal sync).

    -Jesse

    Wednesday, September 30, 2009 9:38 PM

All replies

  • Are you syncing with the FileSyncProvider?  If so, in the update call on your provider you should be able to check the filename by looking at the Name property on the FileData object that you grab from your IFileDataRetriever and compare that to what you currently have. 

    Like this:

    IFileDataRetriever fileData = (IFileDataRetriever)itemData;
    string newFileName= fileData.FileData.Name;

     // oldFileName is the value of your current filename
    if (newFileName != oldFileName)
    {
      // Rename
    }

    In fact, you should be checking the entire relative path of the files to detect moves (if you are doing a heirarchal sync).

    -Jesse

    Wednesday, September 30, 2009 9:38 PM
  • Hey Jesse,


    I'm not using filesyncprovider, i'm using a custom provider, where i capture the filename and the lastwritetime of the file in the metadata and perform sync operation based on them. 

    Pankaj Bajpai. Prosares Solutions ASP.Net | Sharepoint | Consulting SharePoint | ASP.Net | Business Intelligence http://www.prosares.com http://www.linkedin.com/in/pankajbbajpai
    Saturday, October 3, 2009 8:59 AM
  • So you're trying to detect a rename in change detection yourself then?  You could use a heuristic such as if size and lastwritetime haven't changed then assume a rename.  Obviously, you'd have to track size too then.  You could also use a hash.  I don't think there is a property that directly tells you that a file was renamed.

    -Jesse

    Saturday, October 3, 2009 9:07 AM