The Forum has been Updated
The code has been upgraded to the latest .NET core version. Please check instructions in the Community Announcements about migrating your account.
I've written the following script which loops through a directory of images, and outputs an XML file with various attributes of those images. It works just fine but, given that I'm clueless about .NET, is there anything you guys can see that I should be doing differently to make it more efficient? In particular, I'm trying to figure out the .NET equivalent of &_ so I can wrap a string onto a new line - all those response.writes just look wrong to me! Also, is there any way of inserting a variable into a string without having to enclose it in parentheses (It's not really a big deal but, again, it just looks wrong!)?
Code:
<%@page language="VB" debug=true%>
<%@import namespace="system.drawing"%>
<%@import namespace="system.io"%>
<%
response.contenttype="text/xml"
response.write("<?xml version=""1.0"" encoding=""utf-8""?>")
response.write("<images>")
dim objFso=server.createobject("Scripting.FileSystemObject")
dim objFolder=objFso.getfolder(server.mappath("/path/to/directory/"))
dim x,intHeight,intWidth
for each x in objFolder.files
intHeight=0:intWidth=0
using fsFile as new filestream(x.path,filemode.open)
dim bmpImg as new bitmap(bmpImg.fromstream(fsFile))
intWidth=bmpImg.width
intHeight=bmpImg.height
bmpImg.dispose():bmpImg=nothing
end using
response.write("<image>")
response.write("<date>"&(x.datelastmodified)&"</date>")
response.write("<height>"&(intHeight)&"</height>")
response.write("<name>"&(x.name)&"</name>")
response.write("<size>"&(x.size)&"</size>")
response.write("<width>"&(intWidth)&"</width>")
response.write("</image>")
next
objFolder=nothing:objFso=nothing
response.write("</images>")
response.end()
%>
