Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <param name="fileCategory"></param>
        /// <returns></returns>
        public static bool Save(File file, FileCategory fileCategory)
        {
            string path = "";

            switch (fileCategory)
            {
            case FileCategory.Profile:
                //if (!Profile.Exists(file.Info.Name, out path))
                //{
                //    throw new ApplicationException(CustomHttpStatusCode.InvalidUser.ToString("D"));
                //}
                //file.Info.FullPath = path;
                file.Info.FullPath = ConfigurationManager.AppSettings["profileImageSavePath"];
                break;

            case FileCategory.Shared:
                file.Info.FullPath = Shared.GetDirectoryPath(file.Info.FullPath, file.Info.Name, file.Info.MediaType);
                Shared.CreateDirectory(file.Info.FullPath);
                break;

            case FileCategory.Group:
                file.Info.FullPath = Group.CreateDirectory(file.Info.Name);
                break;
            }

            File.Save(file);
            if (FileCategory.Profile == fileCategory)
            {
                file.Info.FullPath = ConfigurationManager.AppSettings["ThumbnailImagesPath"];
                File.SaveMiniProfileImage(file, Convert.ToInt16(ConfigurationManager.AppSettings["MiniProfileWidth"]));
            }
            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <param name="fileCategory"></param>
        /// <returns></returns>
        public static bool Save(File file, FileCategory fileCategory)
        {
            string path = "";

            switch (fileCategory)
            {
            case FileCategory.Profile:
                if (!Profile.Exists(file.Info.Name, out path))
                {
                    throw new ApplicationException(CustomHttpStatusCode.InvalidUser.ToString("D"));
                }
                file.Info.FullPath = path;
                break;

            case FileCategory.Shared:
                file.Info.FullPath = Shared.GetDirectoryPath(file.Info.FullPath, file.Info.Name, file.Info.MediaType);
                Shared.CreateDirectory(file.Info.FullPath);
                break;

            case FileCategory.Group:
                file.Info.FullPath = Group.CreateDirectory(file.Info.Name);
                break;
            }

            File.Save(file);
            return(true);
        }