本文整理匯總了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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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();
}
}
}
示例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("~","");
}
示例7: SetCleanExtractFolder
private static string SetCleanExtractFolder(HttpServerUtilityBase server, string mapPath,
string cleanFileNameNoExtension)
{
var extractFolder = server.MapPath(mapPath + cleanFileNameNoExtension);
MakeOrResetDirectory(extractFolder);
return extractFolder;
}
示例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;
}
示例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);
}
}
示例10: Save
public string Save(HttpServerUtilityBase server, HttpPostedFileBase file)
{
string path = "/Images/" + file.FileName;
string fullPath = server.MapPath(path);
file.SaveAs(fullPath);
return path;
}
示例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);
}
}
示例12: Init
public static void Init(HttpServerUtilityBase server)
{
if (Current == null)
{
_filePath = server.MapPath("~/App_Data/Settings.xml");
Current = GetConnexion();
}
}
示例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);
}
}
示例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);
}
示例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;
}