public static bool FileRename(object fileId, String title, out File file)
        {
            using (var fileDao = Global.DaoFactory.GetFileDao())
            {
                file = fileDao.GetFile(fileId);
                if (file == null)
                {
                    throw new FileNotFoundException(FilesCommonResource.ErrorMassage_FileNotFound);
                }
                if (!Global.GetFilesSecurity().CanEdit(file))
                {
                    throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_RenameFile);
                }
                if (!Global.GetFilesSecurity().CanDelete(file) && CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor())
                {
                    throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_RenameFile);
                }
                if (FileLockedForMe(file.ID))
                {
                    throw new Exception(FilesCommonResource.ErrorMassage_LockedFile);
                }
                if (file.ProviderEntry && FileTracker.IsEditing(file.ID))
                {
                    throw new Exception(FilesCommonResource.ErrorMassage_UpdateEditingFile);
                }
                if (file.RootFolderType == FolderType.TRASH)
                {
                    throw new Exception(FilesCommonResource.ErrorMassage_ViewTrashItem);
                }

                title = Global.ReplaceInvalidCharsAndTruncate(title);

                var ext = FileUtility.GetFileExtension(file.Title);
                if (string.Compare(ext, FileUtility.GetFileExtension(title), true) != 0)
                {
                    title += ext;
                }

                var fileAccess = file.Access;

                var renamed = false;
                if (String.Compare(file.Title, title, false) != 0)
                {
                    var newFileID = fileDao.FileRename(file, title);

                    file        = fileDao.GetFile(newFileID);
                    file.Access = fileAccess;

                    DocumentServiceHelper.RenameFile(file, fileDao);

                    renamed = true;
                }

                SetFileStatus(file);

                return(renamed);
            }
        }