/// <summary>
        /// Recursively re-indexes all the contents of the old (renamed) directory to the new one.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="oldDirectory">The old directory.</param>
        /// <param name="newDirectory">The new directory.</param>
        private static void ReindexDirectory(IFilesStorageProviderV30 provider, string oldDirectory, string newDirectory)
        {
            oldDirectory = NormalizeFullPath(oldDirectory);
            newDirectory = NormalizeFullPath(newDirectory);

            // At this point the directory has been already renamed,
            // thus we must list on the new directory and construct the old name
            // Example: /directory/one/ renamed to /directory/two-two/
            // List on /directory/two-two/
            //     dir1
            //     dir2
            // oldSub = /directory/one/dir1/

            foreach (string sub in provider.ListDirectories(newDirectory))
            {
                string oldSub = oldDirectory + sub.Substring(newDirectory.Length);
                ReindexDirectory(provider, oldSub, sub);
            }

            foreach (string file in provider.ListFiles(newDirectory))
            {
                string oldFile = oldDirectory + file.Substring(newDirectory.Length);
                SearchClass.RenameFile(provider.GetType().FullName + "|" + oldFile, provider.GetType().FullName + "|" + file);
            }
        }
        /// <summary>
        /// Renames and re-indexes a file.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="fullName">The full name of the file to rename.</param>
        /// <param name="newName">The new name of the file (without namespace).</param>
        /// <returns><c>true</c> if the file was renamed, <c>false</c> otherwise.</returns>
        public static bool RenameFile(IFilesStorageProviderV30 provider, string fullName, string newName)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            if (fullName == null)
            {
                throw new ArgumentNullException("fullName");
            }

            if (fullName.Length == 0)
            {
                throw new ArgumentException("Full Name cannot be empty", "fullName");
            }

            if (newName == null)
            {
                throw new ArgumentNullException("newName");
            }

            if (newName.Length == 0)
            {
                throw new ArgumentException("New Name cannot be empty", "newName");
            }

            fullName = NormalizeFullName(fullName);
            string newFullName = GetDirectory(fullName) + newName;

            newFullName = NormalizeFullName(newFullName);

            if (newFullName.ToLowerInvariant() == fullName.ToLowerInvariant())
            {
                return(false);
            }

            bool done = provider.RenameFile(fullName, newFullName);

            if (!done)
            {
                return(false);
            }

            SearchClass.RenameFile(provider.GetType().FullName + "|" + fullName, provider.GetType().FullName + "|" + newFullName);

            Host.Instance.OnFileActivity(provider.GetType().FullName, fullName, newFullName, FileActivity.FileRenamed);

            return(true);
        }