mappath

Delete file on server

社会主义新天地 提交于 2020-01-03 04:59:27
问题 I have a file path in the format file://SERVERNAME/FOLDER$/FOLDER/image.jpg . I call System.IO.File.Delete(Server.MapPath(file://SERVERNAME/FOLDER$/FOLDER/image.jpg)) to delete the file, but i get the error file:/SERVERNAME/FOLDER$/FOLDER/image.jpg' is not a valid virtual path. I notice that a '/' is missing and I do not know why. How will I delete such file? I have tried converting my file path to file:////SERVERNAME//FOLDER$//FOLDER//image.jpg but this did not help. Same thing happens. If I

Classic ASP Server.MapPath() doesn't work as expected in global.asa

浪尽此生 提交于 2019-12-10 11:23:34
问题 In Classic ASP, Server.MapPath() doesn't always work properly in the Application_OnStart event within global.asa . I have an ASP page at "\testfolder\test.asp" within a virtual root, I have an XSLT file at "\xsl\transform.xsl" . My virtual root is located in "c:\inetpub\wwwroot\testapp\" . I use MapPath within the ASP page to get the full path to the XSLT file. The call is: sXslPath = Server.MapPath("xsl\transform.xsl") Some times MapPath returns "c:\inetpub\wwwroot\testapp\xsl\transform.xsl"

Server.MapPath not accepting UNC URL

删除回忆录丶 提交于 2019-12-08 03:51:26
问题 I'm having a bit of trouble loading an XML file with ASP. This is the location of the XML file (it's a UNC url): \\ilife104\teamdisk\Shared\Integration\System\dev\Data\prcImportFactSetFeeds\fileList.xml And this is my code: <% 'load the XML file.. Option Explicit Response.Buffer = True Dim xml Set xml = Server.CreateObject("Microsoft.XMLDOM") xml.async = False xml.load (Server.MapPath("\\ilife104\teamdisk\Shared\Integration\System\dev\Data\prcImportFactSetFeeds\fileList.xml")) Dim name,

Absolute path back to web-relative path

我是研究僧i 提交于 2019-11-26 17:21:50
If I have managed to locate and verify the existence of a file using Server.MapPath and I now want to send the user directly to that file, what is the fastest way to convert that absolute path back into a relative web path? GateKiller Perhaps this might work: String RelativePath = AbsolutePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty); I'm using c# but could be adapted to vb. Wouldn't it be nice to have Server.RelativePath(path) ? well, you just need to extend it ;-) public static class ExtensionMethods { public static string RelativePath(this HttpServerUtility srv,

Absolute path back to web-relative path

笑着哭i 提交于 2019-11-26 04:41:12
问题 If I have managed to locate and verify the existence of a file using Server.MapPath and I now want to send the user directly to that file, what is the fastest way to convert that absolute path back into a relative web path? 回答1: Perhaps this might work: String RelativePath = AbsolutePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty); I'm using c# but could be adapted to vb. 回答2: Wouldn't it be nice to have Server.RelativePath(path) ? well, you just need to extend it ;-)