asp classic: "The system cannot find the path specified" - asp-classic

I'm trying to do server side xml transform and am specifying the templates I want to use in the global.asa
for the paths I specify with server.MapPath. For files in the same folder, some are found and one gives an error. Any idea why?
For example, first one is found, the second one isn't
server.MapPath("/website_root/subFolder/XSL/A.xsl")
server.MapPath("/website_root/subFolder/XSL/B.xsl")
The error says msxml3.dll error '80070003'
The system cannot find the path specified
Thanks in advance.
EDIT:
The problem is with the new templates added, the old declares for the files in the same folder show fine. Code below:
Dim oXSL, oXSLTemplateA, oXSLTemplateB, oXSLTemplateC, oXSLTemplateD, oXSLTemplateE
Set oXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
'A.xsl
oXSL.load server.MapPath("projectRoot/SubFolder/XSL/A.xsl")
Set oXSLTemplateA = Server.CreateObject("Msxml2.XSLTemplate")
oXSLTemplateA.stylesheet = oXSL
Set Application("ATemplate") = oXSLTemplateA
'B.xsl
Set oXSL = Nothing
Set oXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
oXSL.load server.MapPath("/projectRoot/SubFolder/XSL/B.xsl")
Set oXSLTemplateB = Server.CreateObject("Msxml2.XSLTemplate")
oXSLTemplateB.stylesheet = oXSL 'ERROR ON THIS LINE
Set Application("BTemplate") = oXSLTemplateB
'C.xsl
Set oXSL = Nothing
Set oXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
oXSL.load server.MapPath("/projectRoot/SubFolder2/XSL/C.xsl")
Set oXSLTemplateC = Server.CreateObject("Msxml2.XSLTemplate")
oXSLTemplateC.stylesheet = oXSL
Set Application("CTemplate") = oXSLTemplateC
'D.xsl
Set oXSL = Nothing
Set oXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
oXSL.load server.MapPath("/projectRoot/SubFolder2/XSL/D.xsl")
Set oXSLTemplateD = Server.CreateObject("Msxml2.XSLTemplate")
oXSLTemplateD.stylesheet = oXSL
Set Application("DTemplate") = oXSLTemplateD
'E.xsl
Set oXSL = Nothing
Set oXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
oXSL.load server.MapPath("/projectRoot/SubFolder2/XSL/E.xsl")
Set oXSLTemplateE = Server.CreateObject("Msxml2.XSLTemplate")
oXSLTemplateE.stylesheet = oXSL 'ERROR ON THIS LINE
Set Application("ETemplate") = oXSLTemplateE
EDIT:
If I change E.xsl to a random name which I know doesn't exist. The error is different, it'll say msxml3.dll error '80004005' The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

The xsl file was importing another xsl file which was using the full path and wasn't finding anything. I changed that to the relative path and it worked.

Related

VB.net aspX image resize and created file permission denied

I'm trying to create an image based on an original image as a template.
a picture > kapak.jpg - resize to 1366x768 > orta.jpg - resize to 848x480
Code is working. Nothing wrong BUT when I use; code block 2 its locking the file which is kapak.jpg
I can't delete or rename etc. Even if I close the browser or vstudio or all. Nothing changes but restart the iis. I even cant delete it on the file browser as well. It's just locking it and doesnt allow anything. it says that; w3wp.exe or iis express worker is using this file so you cant delete or etc. Access denied.
I tried dispose or =nothing for bitmap
moved code block 2 to another sub
nothing changed.
If I dont use code block 2 it creates and allows me to delete or rename etc.
Any suggestions will be appreciated. How can I set free the file?
button_1_click
gelenIMG.ImageUrl = "\dene_2.jpg"
Dim uzatBOYfark As Integer
Dim uzatENfark As Integer
Dim kapakRESIMayar As New Rectangle(0, 0, 1366, 768)
uzatENfark = kapakRESIMayar.Width : uzatBOYfark = kapakRESIMayar.Height
Using orijinalRESIM = Image.FromFile(Server.MapPath(gelenIMG.ImageUrl))
If orijinalRESIM.Width < kapakRESIMayar.Width Then uzatENfark = kapakRESIMayar.Width * (kapakRESIMayar.Width / orijinalRESIM.Width)
If orijinalRESIM.Height < kapakRESIMayar.Height Then uzatBOYfark = kapakRESIMayar.Height * (kapakRESIMayar.Height / orijinalRESIM.Height)
Using kapakZEMINsablon = New Bitmap(kapakRESIMayar.Width, kapakRESIMayar.Height)
Using grp = Graphics.FromImage(kapakZEMINsablon)
grp.Clear(Color.Red)
grp.DrawImage(orijinalRESIM, New Rectangle(0, 0, uzatENfark, uzatBOYfark + 1), kapakRESIMayar, GraphicsUnit.Pixel)
End Using
kapakZEMINsablon.Save(Server.MapPath(geciciRESIMyeri & "\kapak.jpg"), Imaging.ImageFormat.Jpeg)
End Using
End Using
imgKAPAK.ImageUrl = geciciRESIMyeri & "\kapak.jpg"
code block 2:
Dim bitmapORTA As New Bitmap(Image.FromFile(Server.MapPath(imgKAPAK.ImageUrl), True), 848, 480)
bitmapORTA.Save(Server.MapPath(geciciRESIMyeri & "\orta.jpg"), Imaging.ImageFormat.Jpeg)
imgORTA.ImageUrl = geciciRESIMyeri & "\orta.jpg"

Check if Image Exists on Remote Site ASP.NET VB

I'm trying to get my website to detect if an image exists on the server, display if it does, if it doesn't display another image (which is just called blank.png).
I have tried to use Server.MapPath with relative pathings but havent been able to get it to work. When using Server.MapPath and checking in the broswer after the page has loaded i uses the full path of the file (eg G:\domain\path\blank.png).
If i use The normal path (Dim sImagePath As String = "\Images\DriversNew\"'). The image will display, but the check for whether the image exists or not always returns false. I'm assuming its to do with the physical location of the file.
'Dim sImagePath As String = Server.MapPath("Images/DriversNew/")
Dim sImagePath As String = "\Images\DriversNew\"
Dim sHeadshot As String = sImagePath & dsDriver.Tables("Driver").Rows(0).Item("Name") & ".png"
If File.Exists(sHeadshot) Then
imgDriver.ImageUrl = sHeadshot
Else
imgDriver.ImageUrl = sImagePath & "Blank.png"
End If
Any advice? I know its something simple, but with the reading ive been doing it hasnt been able to get it working on the site.
Thanks, much appreciated!
Assuming that your database column Name contains only the short filename (i.e. no directory path information or folder names) then you can do this:
String nameFromDatabase = (String)dsDriver.Tables("Driver").Rows[0]["Name"] + ".png";
String appRootRelativeHttpResourcePath = "~/Images/DriversNew/" + nameFromDatabase;
String localFileSystemPath = Server.MapPath( appRootRelativeHttpResourcePath );
if( File.Exists( localFileSystemPath ) ) {
imgDriver.ImageUrl = appRootRelativeHttpResourcePath; // you can specify app-root-relative URLs ("~/...") here
}
else {
imgDriver.ImageUrl = "~/Images/DriversNew/Blank.png";
}

Creating XML file in R and saving

I have a problem with saving XML file from R.
Firstly I write my code here:
doc = newXMLDoc()
document = newXMLNode("Document", doc = doc)
set = newXMLNode("Settings", parent = document)
elements = newXMLNode("Elements", parent = set)
newXMLNode("Canvas", parent = elements, attrs = c(Id = "1"))
newXMLNode("Canvas", parent = elements, attrs = c(Id = "2"))
objcol = newXMLNode("ObjectCollection", parent = document)
timeSeries1 = newXMLNode("Timeseries", parent = objcol)
timeSeries2 = newXMLNode("Timeseries", parent = objcol)
saveXML(doc, file="test.dtv", indent = T,
prefix = '<?xml version="1.0" encoding="utf-8" standalone="no"?>\n')
So, if I save doc without prefix, all is good, but i haven't prefix in my ouput file. When I add prefix attribute to function saveXML, output is really bad. It has only one '\n' after prefix(because I write it in prefix string), but all document is on one line. I haven't ideas how to fix it.
Thank you for your attention.
So, I'am also quite surprised why this is not working, but found a "workaround" to it. Hope this is helpfull.
cat(saveXML(doc,
indent = TRUE,
prefix = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n"),
file="test.dtv")

PDFsharp set Width and Height of Page

I'm trying to set the page width and height to 4x6 in PDFsharp from C#. I'm using the following:
page.Width = "4in";
page.Height = "6in";
Still defaults a 8X11 page.
The following code worked for me:
PdfPage page = document.AddPage();
page.Width = "4in";
page.Height = "6in";
Using
pdfPage.Width = XUnit.FromInch(4);
pdfPage.Height = XUnit.FromInch(6);
is better because it avoids string parsing at runtime, but the string version is also working.
Was able to locate the answer to this here is the code to format the page to 4X6 inches:
pdfPage.Width = XUnit.FromInch(4);
pdfPage.Height = XUnit.FromInch(6);

imageresizer.Plugins.Watermark on classic asp

I need to use this plugin to add watermarks to images using classic ASP. I had this work partially using this code:
dim o, b, wm, layer,textlayer
Set b = CreateObject("ImageResizer.Configuration.Config")
Set wm = CreateObject("ImageResizer.Plugins.Watermark.WatermarkPlugin")
Set textlayer = CreateObject("ImageResizer.Plugins.Watermark.TextLayer")
Set layer = CreateObject("ImageResizer.Plugins.Watermark.Layer")
textlayer.Text = "Yeees"
textlayer.fontSize = 50
layer.fill = True
set layer("dd") = textlayer 'THIS IS FAILING
wm.NamedWatermarks("sfdf") = layer("dd") 'THIS IS FAILING TOO
wm.Install(b)
b.BuildImage "C:\lg1_1361_44.jpg", "C:\lg1_1361_44_WATER.png", "watermark=tessst&format=png"
Why are you creating an instance of Layer? TextLayer and ImageLayer are the classes you want to work with
I would drop everything related to 'layer' and try this instead.
textLayer.fill = True
wm.NamedWatermarks("sfdf") = textLayer
You'll also need "watermark=sfdf" instead of "tessst"

Resources