用法:
1.Server.MapPath("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\
2.Server.MapPath("./") 表示所在页面的当前目录
注:等价于Server.MapPath("") 返回 Server.MapPath("")所在页面的物理文件路径
3.Server.MapPath("../")表示上一级目录
4.Server.MapPath("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:C:\Inetpub\wwwroot\Example\
注:等效于Server.MapPath("~")。
语法:Server.MapPath(bstrLogicalPath)
作用:将 bstrLogicalPath 映射为计算机上的物理目录,注意此物理目录可以也可能不存在。
参数:bstrLogicalPath 的意思是相对目录*或虚拟目录。
疑问:bstrLogicalPath 既然既可以表示相对目录,又可以表示虚拟目录,那么它什么时候表示相对目录,什么时候表示虚拟目录呢。
规则:
当 bstrLogicalPath 以 ../ 或 ..\ 开头时,当作相对目录。 <
当 bstrLogicalPath 以斜杠开头( / 或 \ )时,从Web站点根目录(不是物理目录)的角度出发检查是否有匹配的虚拟目录(树)**,如果匹配,则当作虚拟目录,否则当作相对目录。
当 bstrLogicalPath 不以斜杠开头( / 或 \ )时,从Web站点当前目录(不是物理目录)的角度出发检查是否有匹配的虚拟目录(树)**,如果匹配,则当作虚拟目录,否则当作相对目录。
*也可以是文件。
**由于虚拟目录下面可以再建立虚拟目录,所以这里使用虚拟目录树,即:每一层的目录或虚拟目录都要与 bstrLogicalPath 中的对应目录层匹配。
***bstrLogicalPath 中含有英文点(.)或以斜杠结尾( / 或 \ )不影响上述规则。
分享到:
相关推荐
如果您使用的是../folder1/folder2 ...或〜/ folder1 / folder2 ...,则这些文件夹必须作为子... 因此Server.Map(path)[^]仅适用于这些情况。 但是,如果您尝试以绝对路径访问,则必须指定文件的完整路径。 其他...
Path = Server.MapPath("images") & "\clock.jpg" 待处理图片路径 Jpeg.Open Path 打开图片 高与宽为原图片的1/2 Jpeg.Width = Jpeg.OriginalWidth / 2 Jpeg.Height = Jpeg.OriginalHeight / 2 保存图片 Jpeg....
Server.MapPath(Request.ServerVariables[“PATH_INFO”]) Server.MapPath(“/”) Server.MapPath(“”)//当前代码文件所在的目录路劲 Server.MapPath(“.”) Server.MapPath(“../”) Server.MapPath(“..”) ...
string docExtendName = System.IO.Path.GetExtension(sourceDoc).ToLower(); bool result = false; if (docExtendName == ".pdf") { //pdf模板文件 string tempFile = Path.Combine(fileDire, "temppdf.html"...
cName=Server.MapPath("c.cnt") dName=Server.MapPath("d.cnt") Set objCountFile = objFSO.OpenTextFile(cName,1,True) If Not objCountFile.AtEndOfStream Then cnt=CLng(objCountFile.ReadAll) objCountFile....
Directory.CreateDirectory(Path.GetDirectoryName(context.Server.MapPath(saveDir)));//建立文件夹 string fullDir = saveDir + Common.Common.GetStreamMD5(file.InputStream) + fileExtion;//将文件进行MD5...
zip_upFile=Server.MapPath(z_upFile) zip_infile=Server.MapPath("下载说明.txt") zip_doFile=Server.MapPath(z_doFile) zip_uptime=now() randomize zip_ranNum=int(90000*rnd)+10000 zip_ininame=year(zip_uptime...
string directoryName = Path.GetDirectoryName(fullname); string fileName = Path.GetFileName(fullname); if (!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); if (fileName !...
Path = Server.MapPath("../images/apple.jpg") '处理图片路径 Jpeg.Open Path '打开图片 '调整宽度和高度为原来的50% Jpeg.Width = Jpeg.OriginalWidth / 2 Jpeg.Height = Jpeg.OriginalHeight / 2 Jpeg.Save ...
string path = HttpContext.Current.Server.MapPath("/news/"); Encoding code = Encoding.GetEncoding("gb2312"); string temp = HttpContext.Current.Server.MapPath("/news/template.html"); StreamReader...
objbmp.FontPath = server.mappath("font_12.asp") '汉字点阵字库地址 objbmp.loadBMP(server.mappath("bb.bmp")) '调用的BMP图片地址 objbmp.DrawTextWE 2,30,"网海求生者",15 '水平打印汉字DrawTextWE "X点","Y...
string thumbnailFileName = System.IO.Path.GetFileName(gdsImg.Thumbnail); //缩略图文件名 conn.UploadFile(Server.MapPath(dir) + thumbnailFileName, thumbnailFileName); } catch (FtpException e...
Path = Server.MapPath("../images/apple.jpg") '处理图片路径 Jpeg.Open Path '打开图片 '调整宽度和高度为原来的50% Jpeg.Width = Jpeg.OriginalWidth / 2 Jpeg.Height = Jpeg.OriginalHeight / 2 ...
protected void Page_Load(object sender, EventArgs e) { string path = Server.MapPath("xiaofeng.txt"); //创建记事本xiaofeng并写入内容 FileStream fso = new FileStream(path, FileMode....
try { if (FileUpload1.... string serverpath = Server.MapPath("images/") + filename; //string serverpath = @"d:/" + filename; FileUpload1.PostedFile.SaveAs(serverpath); this.lb_info.Text = "上传成功!";
string flv_file = System.IO.Path.ChangeExtension(playFile, ".flv"); string flvmdi = Server.MapPath("../JS/videotool/flvmdi.exe"); //flvmdi修复flv进度条问题 System.Diagnostics.ProcessStartInfo ...
zip_upFile=Server.MapPath(z_upFile) zip_infile=Server.MapPath("下载说明.txt") zip_doFile=Server.MapPath(z_doFile) zip_uptime=now() randomize zip_ranNum=int(90000*rnd)+10000 zip_ininame=year(zip...
Aspose.Cells.License li = new License(); string path = Server.MapPath("License.lic"); li.SetLicense(path); 使用时先注册控件,呵呵
Set Jpeg=Server.CreateObject(“Persits.Jpeg”) path=server.mappath(“s.jpg”) Jpeg.Open path Jpeg.Width=Jpeg.OriginalWidth/3 Jpeg.Height=Jpeg.originalheight /3 Jpeg.Save Server.MapPath(“cut.jpg...
fileName = System.IO.Path.GetFileName(fb.FileName);//获得文件的物理路径 if (string.IsNullOrEmpty(fileName)) { throw new Exception("请添加上传文件!"); } //用年月日时分秒作为文件名,并加上文件的...