當前位置: 首頁>>代碼示例>>C#>>正文


C# HttpServerUtilityBase.MapPath方法代碼示例

本文整理匯總了C#中System.Web.HttpServerUtilityBase.MapPath方法的典型用法代碼示例。如果您正苦於以下問題:C# HttpServerUtilityBase.MapPath方法的具體用法?C# HttpServerUtilityBase.MapPath怎麽用?C# HttpServerUtilityBase.MapPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.HttpServerUtilityBase的用法示例。


在下文中一共展示了HttpServerUtilityBase.MapPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SaveImage

        public Image SaveImage(HttpServerUtilityBase server, HttpPostedFileBase file)
        {
            string largeUploadFolder = server.MapPath("~/assets/images/large");
            string mediumUploadFolder = server.MapPath("~/assets/images/medium");
            string thumbUploadFolder = server.MapPath("~/assets/images/thumb");
            if (!Directory.Exists(largeUploadFolder)) Directory.CreateDirectory(largeUploadFolder);
            if (!Directory.Exists(mediumUploadFolder)) Directory.CreateDirectory(mediumUploadFolder);
            if (!Directory.Exists(thumbUploadFolder)) Directory.CreateDirectory(thumbUploadFolder);

            //The resizing settings can specify any of 30 commands.. See http://imageresizing.net for details.
            ResizeSettings largeSettings = new ResizeSettings("maxwidth=800&maxheight=800");
            ResizeSettings mediumSettings = new ResizeSettings("maxwidth=300&maxheight=300&scale=both");
            ResizeSettings thumbSettings = new ResizeSettings("width=100&height=100&crop=auto");

            //var uniqueName = System.Guid.NewGuid().ToString();
            string uniqueName = PathUtils.RemoveExtension(file.FileName) + "_" + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss");
            string largeFilePath = Path.Combine(largeUploadFolder, uniqueName);
            string mediumFilePath = Path.Combine(mediumUploadFolder, uniqueName);
            string thumbFilePath = Path.Combine(thumbUploadFolder, uniqueName);

            //Let the image builder add the correct extension based on the output file type (which may differ).
            var large = ImageBuilder.Current.Build(file, largeFilePath, largeSettings, false, true);
            var med = ImageBuilder.Current.Build(file, mediumFilePath, mediumSettings, false, true);
            var thumb = ImageBuilder.Current.Build(file, thumbFilePath, thumbSettings, false, true);

            Image img = new Image(PathUtils.RemoveExtension(file.FileName), ResolveRelativePath(server, large), ResolveRelativePath(server, med), ResolveRelativePath(server, thumb));
            Repo.Save(img);
            return img;
        }
開發者ID:s-leonard,項目名稱:Tarts,代碼行數:29,代碼來源:ImageHelper.cs

示例2: Delete

 public void Delete(HttpServerUtilityBase server, Image img)
 {
     try { System.IO.File.Delete(server.MapPath(img.Large)); } catch {}
     try { System.IO.File.Delete(server.MapPath(img.Medium)); } catch {}
     try { System.IO.File.Delete(server.MapPath(img.Thumb)); } catch {}
     Repo.Delete(img);
 }
開發者ID:s-leonard,項目名稱:Tarts,代碼行數:7,代碼來源:ImageHelper.cs

示例3: delete_mvc_use_only

        public Boolean delete_mvc_use_only(int id, HttpServerUtilityBase server_context)
        {
            try
             {
                HinhAnh kq = this.get_by_id(id);
                if (kq == null) return false;
                //first delete file
                try
                {
                    String directory = "~/_Upload/HinhAnh/";
                    System.IO.File.Delete(server_context.MapPath(Path.Combine(directory, kq.duongdan)));
                    System.IO.File.Delete(server_context.MapPath(Path.Combine(directory, kq.duongdan_thumb)));

                }
                catch (Exception ex)
                {
                    Debug.WriteLine("qqqqqqqqqqqq"+ex.ToString());
                }
                //delete in database
                _db.ds_hinhanh.Remove(kq);
                _db.SaveChanges();
                return true;
             }
             catch (Exception ex)
             {
                 Debug.WriteLine(ex.ToString());
                 return false;
             }
        }
開發者ID:quocdunginfo,項目名稱:CuaHangDTDD,代碼行數:29,代碼來源:HinhAnhController.cs

示例4: GetEntryPoint

        private static string GetEntryPoint(HttpServerUtilityBase server, string filePath, string root)
        {

            var fileName = PathHelpers.GetExactFilePath(filePath);
            var folder = server.MapPath(root);
            return PathHelpers.GetRequireRelativePath(folder, fileName);
        }
開發者ID:philipooo,項目名稱:RequireJSDotNet,代碼行數:7,代碼來源:DefaultEntryPointResolver.cs

示例5: PRCImageCollection

        public PRCImageCollection(HttpServerUtilityBase Server, string PRCRef)
        {
            this.PRCRef = PRCRef;
            this.ServerPath = new DirectoryInfo(Server.MapPath(@"~\"));

            this.CarouselImagesDirectoryPath = new DirectoryInfo(this.ServerPath + "CarouselImages\\" + PRCRef);
            this.PropertyImagesDirectoryPath = new DirectoryInfo(this.ServerPath + "PropertyImages\\" + PRCRef);

            //get all directories and files and create PRCImages
            GetAllImagesFromADirectoryAndPlaceInACollection(CarouselImagesDirectoryPath, CarouselImageList, this.CarouselImagesExists);
            GetAllImagesFromADirectoryAndPlaceInACollection(PropertyImagesDirectoryPath, PropertyImageList, this.PropertyImagesExists);

            if (CarouselImageList.Count > 0)
            {
                CarouselImagesExists = true;
                foreach (var image in CarouselImageList)
                {
                    image.CapitalizeCamelCasedString();

                }
            }
            if (PropertyImageList.Count > 0)
            {
                PropertyImagesExists = true;
                foreach (var image in PropertyImageList)
                {
                    image.CapitalizeCamelCasedString();

                }

            }
        }
開發者ID:nadavdrewe,項目名稱:portugalvillas,代碼行數:32,代碼來源:ImageUtility.cs

示例6: ResolveRelativePath

 private static string ResolveRelativePath(HttpServerUtilityBase server, string physicalPath)
 {
     //C:\@Projects\Tarts\Tarts.Web\assets\images\large\1040c396-c558-473e-a3ca-f20de6ab13d2.jpg
     string relative = "~/assets/images";
     string physical = server.MapPath(relative);
     return physicalPath.Replace(physical, relative).Replace("\\", "/").Replace("~","");
 }
開發者ID:s-leonard,項目名稱:Tarts,代碼行數:7,代碼來源:ImageHelper.cs

示例7: SetCleanExtractFolder

 private static string SetCleanExtractFolder(HttpServerUtilityBase server, string mapPath,
     string cleanFileNameNoExtension)
 {
     var extractFolder = server.MapPath(mapPath + cleanFileNameNoExtension);
     MakeOrResetDirectory(extractFolder);
     return extractFolder;
 }
開發者ID:rswetnam,項目名稱:GoodBoating,代碼行數:7,代碼來源:FileServices.cs

示例8: SwtorzFirme

        internal Firma SwtorzFirme(HttpServerUtilityBase server, HttpPostedFileBase uploadFile)
        {
            string url = string.Empty;
            if (uploadFile != null && uploadFile.FileName != string.Empty)
            {
                url = Path.Combine(server.MapPath("~/Images/firmy"), uploadFile.FileName);
                uploadFile.SaveAs(url);
                url = Path.Combine("../Images/firmy", uploadFile.FileName);
            }

            Firma firma = new Firma
            {
                nazwa = nazwa,
                zdjecie = url,
                adres = new Adres
                {
                    ulica = ulica,
                    numer_budynku = numer_budynku,
                    numer_lokalu = numer_lokalu,
                },
                kontakt = new Kontakt
                {
                    mail = mail,
                    numer_komurkowy = numer_komurkowy
                },
            };

            return firma;
        }
開發者ID:przemko07,項目名稱:ZaliczenieTenglera,代碼行數:29,代碼來源:NowaFirmaVM.cs

示例9: GetImageMetadata

        public static ImageMetadata GetImageMetadata(HttpServerUtilityBase server, string imageUrl)
        {
            string path = server.MapPath(imageUrl + ".meta");

            using (var reader = new StreamReader(path)) {
                return new ImageMetadata(imageUrl, reader);
            }
        }
開發者ID:JanivZ,項目名稱:letmebingthatforyou,代碼行數:8,代碼來源:ImageMetadata.cs

示例10: Save

        public string Save(HttpServerUtilityBase server, HttpPostedFileBase file)
        {
            string path = "/Images/" + file.FileName;
            string fullPath = server.MapPath(path);
            file.SaveAs(fullPath);

            return path;
        }
開發者ID:M-Yankov,項目名稱:UniversityStudentSystem,代碼行數:8,代碼來源:NewsImageUpload.cs

示例11: Del

 /// <summary>
 /// Elimina un album e tutto il suo contenuto
 /// </summary>
 /// <param name="Server">Server object per MapPath</param>
 /// <param name="name">Nome dell'album (e nome cartella)</param>
 public static void Del(HttpServerUtilityBase Server, string name)
 {
     string path = Server.MapPath(BASE_PATH + "/" + name);
     if (Directory.Exists(path))
     {
         Directory.Delete(path, true);
     }
 }
開發者ID:baffo88,項目名稱:Funblades,代碼行數:13,代碼來源:Albums.cs

示例12: Init

 public static void Init(HttpServerUtilityBase server)
 {
     if (Current == null)
     {
         _filePath = server.MapPath("~/App_Data/Settings.xml");
         Current = GetConnexion();
     }
 }
開發者ID:Tarboeuf,項目名稱:hubiC.net,代碼行數:8,代碼來源:ConnexionHelper.cs

示例13: FileRepository

 public FileRepository(ISettingsProvider settingsProvider, HttpServerUtilityBase server)
 {
     root = settingsProvider.GetSettings<Settings.FunnelWebSettings>().UploadPath;
     // If it's a virtual path then we can map it, otherwise we'll expect that it's a windows path
     if (root.StartsWith("~"))
     {
         root = server.MapPath(root);
     }
 }
開發者ID:HarryMcCarney,項目名稱:Fungle-web,代碼行數:9,代碼來源:FileRepository.cs

示例14: DebugVirtualPath

 static string DebugVirtualPath(string filename, HttpServerUtilityBase server)
 {
     return String.Format("/{0}", filename);
     // Use query string to break caching. This means the file's path
     // still matches the development file system.
     var absoluteFilename = server.MapPath("~/" + filename);
     var version = File.GetLastWriteTime(absoluteFilename).Ticks.ToString();
     return String.Format("/static/{0}./{1}", version, filename);
 }
開發者ID:ogvlad,項目名稱:netbasics,代碼行數:9,代碼來源:StaticFileHelper.cs

示例15: DebugVirtualPath

 static string DebugVirtualPath(string filename, HttpServerUtilityBase server)
 {
     // Use query string to break caching. This means the file's path
     // still matches the development file system.
     var absoluteFilename = server.MapPath("~/static/" + filename);
     var version = File.GetLastWriteTime(absoluteFilename).Ticks.ToString();
     var separator = (filename.Contains("?") ? "&" : "?");
     return "/static/" + filename + separator + "nocache=" + version;
 }
開發者ID:mkhj,項目名稱:EcoHotels,代碼行數:9,代碼來源:UrlHelperExtensions.cs


注:本文中的System.Web.HttpServerUtilityBase.MapPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。