Exemplo n.º 1
0
        /// <summary>
        /// Deletes and de-indexes a file.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="fullName">The full name of the file to delete.</param>
        /// <returns><c>true</c> if the file was deleted, <c>false</c> otherwise.</returns>
        public static bool DeleteFile(IFilesStorageProviderV40 provider, string fullName)
        {
            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");
            }

            fullName = NormalizeFullName(fullName);

            bool done = provider.DeleteFile(fullName);

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

            SearchClass.UnindexFile(provider.GetType().FullName + "|" + fullName, provider.CurrentWiki);

            Host.Instance.OnFileActivity(provider.GetType().FullName, fullName, null, FileActivity.FileDeleted);

            return(true);
        }