Esempio n. 1
0
        public static string GetSavedFile(Telerik.Web.UI.UploadedFile fUploader, bool autoGenerateName)
        {
            string guid = string.Empty;

            if (fUploader != null)
            {
                try
                {
                    if (!fUploader.FileName.Contains('.'))
                        return guid;

                    if (autoGenerateName)
                    {
                        guid = Guid.NewGuid().ToString();
                        guid += fUploader.GetExtension();
                    }
                    else
                        guid = fUploader.GetName();
                    if (File.Exists(ExpressoConfig.GeneralConfigElement.GetPhysicalUploadPath + "\\" + guid))
                    {
                        guid = fUploader.GetNameWithoutExtension() + "_" + Guid.NewGuid().ToString().Substring(0, 3).ToString() + fUploader.GetExtension();
                    }
                    fUploader.SaveAs(ExpressoConfig.GeneralConfigElement.GetPhysicalUploadPath + "\\" + guid);

                }


                catch (Exception ex)
                {
                    throw ex;
                }

            }
            return guid;
        }