473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Tweak to existing code-scanning folders for new files

Hello group.
I have some code (given to me), but I don't know alot about ASP, so I was
hoping someone here can help. Running on Win 2008 server.

The code below will scan a folder and subfolder with a date/time input and
return xml structure off all files that are newer than the supplied date/time.

The problem is that the returned xml has path names like
C:\folder\subfolder\filename.ext
I would like it to be more like /folder/subfolder/filename.ext
Also, the initial path gets returned in the xml "data", but I only want the
sub folders below "data" to get scanned and info returned...
Any help would be greatly appreciated.

function indent(iTreeLevel)
dim rv : rv = ""
if iTreeLevel 0 then
for i = 1 to iTreeLevel
rv = rv & " "
next
end if
indent = rv
end function

'==========================================

function newItemsCount(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + 1
End If
Next
newItemsCount = rv
end function

'==========================================

function newItemsSize(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + objFile.Size
End If
Next
newItemsSize = rv
end function

'==========================================

sub FolderListing(strPath, dCutoffDate, blnRecursive, iTreeLevel)

Dim objFolder
Set objFolder = objFSO.GetFolder(strPath)

response.write(indent(iTreeLevel) & "<folder name=""" & objFolder.Name &
""" newitems=""" & newItemsCount(objFolder, dCutoffDate) & """
newitems_size=""" & newItemsSize(objFolder, dCutoffDate) & """>" & vbCrLf)

For Each objFile In objFolder.Files
sFileSize = objFile.Size
sFileName = objFile.Name
sFileType = objFile.Type
sFileCreated = objFile.DateCreated
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
response.write(indent(iTreeLevel) & " <file name=""" & sFileName & """
size=""" & sFileSize & """ date=""" & sFileModified & """ url=""" & strPath &
"\" & sFileName & """/>" & vbCrLf)
End If
Next

If blnRecursive Then
Dim objSubFolders
Set objSubFolders = objFolder.SubFolders
For Each objFolder in objSubFolders
sFolderName = objFolder.Name
sFolderPath = strPath & "\" & sFolderName
FolderListing sFolderPath, dCutoffDate, blnRecursive, iTreeLevel+1
Next
End if

response.write(indent(iTreeLevel) & "</folder>" & vbCrLf)

end sub

'================================================= ========================================
sDateTime = unescape(Request.QueryString)
aDateTime = split(sDateTime, " ")
sDate = aDateTime(0)
sTime = aDateTime(1) & " " & aDateTime(2)
dDate = DateValue(sDate)
dTime = TimeValue(sTime)
dDateTime = dDate + dTime

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
%>

<?xml version="1.0" encoding="utf-8"?>

<newfiles fromdate="<%= dDate %>" datestr="<%= sDate %>" timestr="<%= sTime
%>" resultdatetime="<%= dDateTime %>">

<%
FolderListing server.MapPath("data"), dDateTime, true, 0
%>

</newfiles>
--
Thanks!
Bryan
Aug 19 '08 #1
8 1730
"Bryan" <Br***@discussions.microsoft.comwrote in message
news:8D**********************************@microsof t.com...
Hello group.
I have some code (given to me), but I don't know alot about ASP, so I was
hoping someone here can help. Running on Win 2008 server.

The code below will scan a folder and subfolder with a date/time input and
return xml structure off all files that are newer than the supplied
date/time.
>
The problem is that the returned xml has path names like
C:\folder\subfolder\filename.ext
I would like it to be more like /folder/subfolder/filename.ext
Also, the initial path gets returned in the xml "data", but I only want
the
sub folders below "data" to get scanned and info returned...
Any help would be greatly appreciated.

function indent(iTreeLevel)
dim rv : rv = ""
if iTreeLevel 0 then
for i = 1 to iTreeLevel
rv = rv & " "
next
end if
indent = rv
end function

'==========================================

function newItemsCount(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + 1
End If
Next
newItemsCount = rv
end function

'==========================================

function newItemsSize(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + objFile.Size
End If
Next
newItemsSize = rv
end function

'==========================================

sub FolderListing(strPath, dCutoffDate, blnRecursive, iTreeLevel)

Dim objFolder
Set objFolder = objFSO.GetFolder(strPath)

response.write(indent(iTreeLevel) & "<folder name=""" & objFolder.Name &
""" newitems=""" & newItemsCount(objFolder, dCutoffDate) & """
newitems_size=""" & newItemsSize(objFolder, dCutoffDate) & """>" & vbCrLf)

For Each objFile In objFolder.Files
sFileSize = objFile.Size
sFileName = objFile.Name
sFileType = objFile.Type
sFileCreated = objFile.DateCreated
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
response.write(indent(iTreeLevel) & " <file name=""" & sFileName & """
size=""" & sFileSize & """ date=""" & sFileModified & """ url=""" &
strPath &
"\" & sFileName & """/>" & vbCrLf)
End If
Next

If blnRecursive Then
Dim objSubFolders
Set objSubFolders = objFolder.SubFolders
For Each objFolder in objSubFolders
sFolderName = objFolder.Name
sFolderPath = strPath & "\" & sFolderName
FolderListing sFolderPath, dCutoffDate, blnRecursive, iTreeLevel+1
Next
End if

response.write(indent(iTreeLevel) & "</folder>" & vbCrLf)

end sub

'================================================= ==========================
==============
>

sDateTime = unescape(Request.QueryString)
aDateTime = split(sDateTime, " ")
sDate = aDateTime(0)
sTime = aDateTime(1) & " " & aDateTime(2)
dDate = DateValue(sDate)
dTime = TimeValue(sTime)
dDateTime = dDate + dTime

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
%>

<?xml version="1.0" encoding="utf-8"?>

<newfiles fromdate="<%= dDate %>" datestr="<%= sDate %>" timestr="<%=
sTime
%>" resultdatetime="<%= dDateTime %>">

<%
FolderListing server.MapPath("data"), dDateTime, true, 0
%>

</newfiles>


Could not bring myself to tweak that code. Here is an alternative ASP:-

<%

Dim gfso : Set gfso = Server.CreateObject("Scripting.FileSystemObject")
Dim gdatCutOff : gdatCutOff = FromISO8601(Request.QueryString("cutoff"))

Dim goXML : Set goXML = Server.CreateObject("MSXML2.DOMDocument.6.0")
goXML.LoadXML "<newItems />"

Dim gelemNewFiles : Set gelemNewFiles = goXML.documentElement

gelemNewFiles.setAttribute "from", ToISO8601(gdatCutOff)

Dim goDataFolder : Set goDataFolder = gfso.GetFolder(Server.MapPath("data"))

GetFolderXML gelemNewFiles, goDataFolder, gdatCutOff

DropElems gelemNewFiles, "folder[@name='data']/file"

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
goXML.Save Response

Sub GetFolderXML(relemParent, roFolder, rdatCutOff)

Dim oFolder
Dim oFile
Dim elemFolder
Dim elemFile

Set elemFolder = AddElem(relemParent, "folder", Null)
elemFolder.setAttribute "name", roFolder.Name

For Each oFolder In roFolder.SubFolders
GetFolderXML elemFolder, oFolder, rdatCutOff
Next

For Each oFile In roFolder.Files
If oFile.DateLastModified rdatCutOff Then
Set elemFile = AddElem(elemFolder, "file", Null)
elemFile.setAttribute "name", oFile.Name
elemFile.setAttribute "size", oFile.Size
elemFile.setAttribute "lastModified", ToISO8601(oFile.DateLastModified)
End If
Next

End Sub

Sub DropElems(relem, rsXPath)

Dim oNode
Dim oList : Set oList = relem.SelectNodes(rsXPath)
Dim lDummy : lDummy = oList.length 'Fill list
For Each oNode in oList
oNode.parentNode.removeChild oNode
Next

End Sub

Function FromISO8601(s)
'See http://www.merlyn.demon.co.uk/vb-date1.htm#DS
' Returns date in local time if timezone not present or GMT if timezone is
present
FromISO8601 = DateSerial(Mid(s,1,4), Mid(s,5,2), Mid(s,7,2))

If Len(s) 8 Then
FromISO8601 = FromISO8601 + CDate(Mid(s,10,8))
End If

If Len(s) 17 Then
FromISO8601 = FromISO8601 - CInt(Mid(s,18,1) & "1") * CDate(Mid(s,19,5))
End If

End Function

Function ToISO8601(rdat)
'See http://www.merlyn.demon.co.uk/vb-date1.htm#Cymd

Dim sYMD : sYMD = CStr((Year(rdat)*100 + Month(rdat) )*100 + Day(rdat))
Dim sHMS : sHMS = Right((Hour(rdat)*100+Minute(rdat))*100+Second(rda t)+1e7,
6)

ToISO8601 = sYMD & "T" & Left(sHMS, 2) & ":" & Mid(sHMS, 3,2) & ":" &
Right(sHMS, 2)

End Function

Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) Then AddElem.Text = rvntValue
End Function
%>
Its not a good idea to attempt to build XML output using response writes.
The code does not properly encode characters that have meaning in XML nor
was the character encoding correct. Had any files contained a & or a
character outside the base ASCII range the generated output would be
corrupt. My code uses DOM to build the XML, it makes the code much more
readable as well.

Note that my code uses ISO8601 formating for the date values all the
original code. Also it does not even attempt to place path info into the XML
nor does it include counts or size totals. All of these pieces of info can
be derived from the XML.

I have included your request to drop files found in the data folder itself
although I would have prefered that the data folder not have other files in
it. (Caveat, the folder name 'data' is case sensitive).

Call this page like this:-

/root/listnewfiles.asp?cutoff=20080819T21:30:00

What do you do with this XML once received?
--
Anthony Jones - MVP ASP/ASP.NET
Aug 19 '08 #2
Anthony,
Thanks for the sample code... I'll try it out..
The code is used by another compiled program to download files from a web
server. Basically all files that are newer than the cutoff date are returned
in the xml, then another program downloads the files. I don't have any
control over the other program, so the xml has to look/function like the
existing xml to work.
Thanks again!
--
Thanks!
Bryan
"Anthony Jones" wrote:
"Bryan" <Br***@discussions.microsoft.comwrote in message
news:8D**********************************@microsof t.com...
Hello group.
I have some code (given to me), but I don't know alot about ASP, so I was
hoping someone here can help. Running on Win 2008 server.

The code below will scan a folder and subfolder with a date/time input and
return xml structure off all files that are newer than the supplied
date/time.

The problem is that the returned xml has path names like
C:\folder\subfolder\filename.ext
I would like it to be more like /folder/subfolder/filename.ext
Also, the initial path gets returned in the xml "data", but I only want
the
sub folders below "data" to get scanned and info returned...
Any help would be greatly appreciated.

function indent(iTreeLevel)
dim rv : rv = ""
if iTreeLevel 0 then
for i = 1 to iTreeLevel
rv = rv & " "
next
end if
indent = rv
end function

'==========================================

function newItemsCount(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + 1
End If
Next
newItemsCount = rv
end function

'==========================================

function newItemsSize(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + objFile.Size
End If
Next
newItemsSize = rv
end function

'==========================================

sub FolderListing(strPath, dCutoffDate, blnRecursive, iTreeLevel)

Dim objFolder
Set objFolder = objFSO.GetFolder(strPath)

response.write(indent(iTreeLevel) & "<folder name=""" & objFolder.Name &
""" newitems=""" & newItemsCount(objFolder, dCutoffDate) & """
newitems_size=""" & newItemsSize(objFolder, dCutoffDate) & """>" & vbCrLf)

For Each objFile In objFolder.Files
sFileSize = objFile.Size
sFileName = objFile.Name
sFileType = objFile.Type
sFileCreated = objFile.DateCreated
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
response.write(indent(iTreeLevel) & " <file name=""" & sFileName & """
size=""" & sFileSize & """ date=""" & sFileModified & """ url=""" &
strPath &
"\" & sFileName & """/>" & vbCrLf)
End If
Next

If blnRecursive Then
Dim objSubFolders
Set objSubFolders = objFolder.SubFolders
For Each objFolder in objSubFolders
sFolderName = objFolder.Name
sFolderPath = strPath & "\" & sFolderName
FolderListing sFolderPath, dCutoffDate, blnRecursive, iTreeLevel+1
Next
End if

response.write(indent(iTreeLevel) & "</folder>" & vbCrLf)

end sub
'================================================= ==========================
==============


sDateTime = unescape(Request.QueryString)
aDateTime = split(sDateTime, " ")
sDate = aDateTime(0)
sTime = aDateTime(1) & " " & aDateTime(2)
dDate = DateValue(sDate)
dTime = TimeValue(sTime)
dDateTime = dDate + dTime

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
%>

<?xml version="1.0" encoding="utf-8"?>

<newfiles fromdate="<%= dDate %>" datestr="<%= sDate %>" timestr="<%=
sTime
%>" resultdatetime="<%= dDateTime %>">

<%
FolderListing server.MapPath("data"), dDateTime, true, 0
%>

</newfiles>


Could not bring myself to tweak that code. Here is an alternative ASP:-

<%

Dim gfso : Set gfso = Server.CreateObject("Scripting.FileSystemObject")
Dim gdatCutOff : gdatCutOff = FromISO8601(Request.QueryString("cutoff"))

Dim goXML : Set goXML = Server.CreateObject("MSXML2.DOMDocument.6.0")
goXML.LoadXML "<newItems />"

Dim gelemNewFiles : Set gelemNewFiles = goXML.documentElement

gelemNewFiles.setAttribute "from", ToISO8601(gdatCutOff)

Dim goDataFolder : Set goDataFolder = gfso.GetFolder(Server.MapPath("data"))

GetFolderXML gelemNewFiles, goDataFolder, gdatCutOff

DropElems gelemNewFiles, "folder[@name='data']/file"

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
goXML.Save Response

Sub GetFolderXML(relemParent, roFolder, rdatCutOff)

Dim oFolder
Dim oFile
Dim elemFolder
Dim elemFile

Set elemFolder = AddElem(relemParent, "folder", Null)
elemFolder.setAttribute "name", roFolder.Name

For Each oFolder In roFolder.SubFolders
GetFolderXML elemFolder, oFolder, rdatCutOff
Next

For Each oFile In roFolder.Files
If oFile.DateLastModified rdatCutOff Then
Set elemFile = AddElem(elemFolder, "file", Null)
elemFile.setAttribute "name", oFile.Name
elemFile.setAttribute "size", oFile.Size
elemFile.setAttribute "lastModified", ToISO8601(oFile.DateLastModified)
End If
Next

End Sub

Sub DropElems(relem, rsXPath)

Dim oNode
Dim oList : Set oList = relem.SelectNodes(rsXPath)
Dim lDummy : lDummy = oList.length 'Fill list
For Each oNode in oList
oNode.parentNode.removeChild oNode
Next

End Sub

Function FromISO8601(s)
'See http://www.merlyn.demon.co.uk/vb-date1.htm#DS
' Returns date in local time if timezone not present or GMT if timezone is
present
FromISO8601 = DateSerial(Mid(s,1,4), Mid(s,5,2), Mid(s,7,2))

If Len(s) 8 Then
FromISO8601 = FromISO8601 + CDate(Mid(s,10,8))
End If

If Len(s) 17 Then
FromISO8601 = FromISO8601 - CInt(Mid(s,18,1) & "1") * CDate(Mid(s,19,5))
End If

End Function

Function ToISO8601(rdat)
'See http://www.merlyn.demon.co.uk/vb-date1.htm#Cymd

Dim sYMD : sYMD = CStr((Year(rdat)*100 + Month(rdat) )*100 + Day(rdat))
Dim sHMS : sHMS = Right((Hour(rdat)*100+Minute(rdat))*100+Second(rda t)+1e7,
6)

ToISO8601 = sYMD & "T" & Left(sHMS, 2) & ":" & Mid(sHMS, 3,2) & ":" &
Right(sHMS, 2)

End Function

Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) Then AddElem.Text = rvntValue
End Function
%>
Its not a good idea to attempt to build XML output using response writes.
The code does not properly encode characters that have meaning in XML nor
was the character encoding correct. Had any files contained a & or a
character outside the base ASCII range the generated output would be
corrupt. My code uses DOM to build the XML, it makes the code much more
readable as well.

Note that my code uses ISO8601 formating for the date values all the
original code. Also it does not even attempt to place path info into the XML
nor does it include counts or size totals. All of these pieces of info can
be derived from the XML.

I have included your request to drop files found in the data folder itself
although I would have prefered that the data folder not have other files in
it. (Caveat, the folder name 'data' is case sensitive).

Call this page like this:-

/root/listnewfiles.asp?cutoff=20080819T21:30:00

What do you do with this XML once received?
--
Anthony Jones - MVP ASP/ASP.NET
Aug 19 '08 #3
Anthony,
I've put the asp file in a folder just above the 'data' folder....
so C:\........\GT\data
The asp is located in the GT folder.
I get an internal error.
I'm calling it like this:
http://www.hurricanealley.net/GT/tes...80819T21:30:00

Any suggestions?
Thanks again,
Bryan

--
Thanks!
Bryan
"Anthony Jones" wrote:
"Bryan" <Br***@discussions.microsoft.comwrote in message
news:8D**********************************@microsof t.com...
Hello group.
I have some code (given to me), but I don't know alot about ASP, so I was
hoping someone here can help. Running on Win 2008 server.

The code below will scan a folder and subfolder with a date/time input and
return xml structure off all files that are newer than the supplied
date/time.

The problem is that the returned xml has path names like
C:\folder\subfolder\filename.ext
I would like it to be more like /folder/subfolder/filename.ext
Also, the initial path gets returned in the xml "data", but I only want
the
sub folders below "data" to get scanned and info returned...
Any help would be greatly appreciated.

function indent(iTreeLevel)
dim rv : rv = ""
if iTreeLevel 0 then
for i = 1 to iTreeLevel
rv = rv & " "
next
end if
indent = rv
end function

'==========================================

function newItemsCount(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + 1
End If
Next
newItemsCount = rv
end function

'==========================================

function newItemsSize(objFolder, dCutoffDate)
dim rv : rv = 0
dim sFileModified
For Each objFile In objFolder.Files
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
rv = rv + objFile.Size
End If
Next
newItemsSize = rv
end function

'==========================================

sub FolderListing(strPath, dCutoffDate, blnRecursive, iTreeLevel)

Dim objFolder
Set objFolder = objFSO.GetFolder(strPath)

response.write(indent(iTreeLevel) & "<folder name=""" & objFolder.Name &
""" newitems=""" & newItemsCount(objFolder, dCutoffDate) & """
newitems_size=""" & newItemsSize(objFolder, dCutoffDate) & """>" & vbCrLf)

For Each objFile In objFolder.Files
sFileSize = objFile.Size
sFileName = objFile.Name
sFileType = objFile.Type
sFileCreated = objFile.DateCreated
sFileModified = objFile.DateLastModified
If (sFileModified dCutoffDate) Then
response.write(indent(iTreeLevel) & " <file name=""" & sFileName & """
size=""" & sFileSize & """ date=""" & sFileModified & """ url=""" &
strPath &
"\" & sFileName & """/>" & vbCrLf)
End If
Next

If blnRecursive Then
Dim objSubFolders
Set objSubFolders = objFolder.SubFolders
For Each objFolder in objSubFolders
sFolderName = objFolder.Name
sFolderPath = strPath & "\" & sFolderName
FolderListing sFolderPath, dCutoffDate, blnRecursive, iTreeLevel+1
Next
End if

response.write(indent(iTreeLevel) & "</folder>" & vbCrLf)

end sub
'================================================= ==========================
==============


sDateTime = unescape(Request.QueryString)
aDateTime = split(sDateTime, " ")
sDate = aDateTime(0)
sTime = aDateTime(1) & " " & aDateTime(2)
dDate = DateValue(sDate)
dTime = TimeValue(sTime)
dDateTime = dDate + dTime

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
%>

<?xml version="1.0" encoding="utf-8"?>

<newfiles fromdate="<%= dDate %>" datestr="<%= sDate %>" timestr="<%=
sTime
%>" resultdatetime="<%= dDateTime %>">

<%
FolderListing server.MapPath("data"), dDateTime, true, 0
%>

</newfiles>


Could not bring myself to tweak that code. Here is an alternative ASP:-

<%

Dim gfso : Set gfso = Server.CreateObject("Scripting.FileSystemObject")
Dim gdatCutOff : gdatCutOff = FromISO8601(Request.QueryString("cutoff"))

Dim goXML : Set goXML = Server.CreateObject("MSXML2.DOMDocument.6.0")
goXML.LoadXML "<newItems />"

Dim gelemNewFiles : Set gelemNewFiles = goXML.documentElement

gelemNewFiles.setAttribute "from", ToISO8601(gdatCutOff)

Dim goDataFolder : Set goDataFolder = gfso.GetFolder(Server.MapPath("data"))

GetFolderXML gelemNewFiles, goDataFolder, gdatCutOff

DropElems gelemNewFiles, "folder[@name='data']/file"

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
goXML.Save Response

Sub GetFolderXML(relemParent, roFolder, rdatCutOff)

Dim oFolder
Dim oFile
Dim elemFolder
Dim elemFile

Set elemFolder = AddElem(relemParent, "folder", Null)
elemFolder.setAttribute "name", roFolder.Name

For Each oFolder In roFolder.SubFolders
GetFolderXML elemFolder, oFolder, rdatCutOff
Next

For Each oFile In roFolder.Files
If oFile.DateLastModified rdatCutOff Then
Set elemFile = AddElem(elemFolder, "file", Null)
elemFile.setAttribute "name", oFile.Name
elemFile.setAttribute "size", oFile.Size
elemFile.setAttribute "lastModified", ToISO8601(oFile.DateLastModified)
End If
Next

End Sub

Sub DropElems(relem, rsXPath)

Dim oNode
Dim oList : Set oList = relem.SelectNodes(rsXPath)
Dim lDummy : lDummy = oList.length 'Fill list
For Each oNode in oList
oNode.parentNode.removeChild oNode
Next

End Sub

Function FromISO8601(s)
'See http://www.merlyn.demon.co.uk/vb-date1.htm#DS
' Returns date in local time if timezone not present or GMT if timezone is
present
FromISO8601 = DateSerial(Mid(s,1,4), Mid(s,5,2), Mid(s,7,2))

If Len(s) 8 Then
FromISO8601 = FromISO8601 + CDate(Mid(s,10,8))
End If

If Len(s) 17 Then
FromISO8601 = FromISO8601 - CInt(Mid(s,18,1) & "1") * CDate(Mid(s,19,5))
End If

End Function

Function ToISO8601(rdat)
'See http://www.merlyn.demon.co.uk/vb-date1.htm#Cymd

Dim sYMD : sYMD = CStr((Year(rdat)*100 + Month(rdat) )*100 + Day(rdat))
Dim sHMS : sHMS = Right((Hour(rdat)*100+Minute(rdat))*100+Second(rda t)+1e7,
6)

ToISO8601 = sYMD & "T" & Left(sHMS, 2) & ":" & Mid(sHMS, 3,2) & ":" &
Right(sHMS, 2)

End Function

Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
roParent.appendChild AddElem
If Not IsNull(rvntValue) Then AddElem.Text = rvntValue
End Function
%>
Its not a good idea to attempt to build XML output using response writes.
The code does not properly encode characters that have meaning in XML nor
was the character encoding correct. Had any files contained a & or a
character outside the base ASCII range the generated output would be
corrupt. My code uses DOM to build the XML, it makes the code much more
readable as well.

Note that my code uses ISO8601 formating for the date values all the
original code. Also it does not even attempt to place path info into the XML
nor does it include counts or size totals. All of these pieces of info can
be derived from the XML.

I have included your request to drop files found in the data folder itself
although I would have prefered that the data folder not have other files in
it. (Caveat, the folder name 'data' is case sensitive).

Call this page like this:-

/root/listnewfiles.asp?cutoff=20080819T21:30:00

What do you do with this XML once received?
--
Anthony Jones - MVP ASP/ASP.NET
Aug 20 '08 #4
"Bryan" <Br***@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
Anthony,
I've put the asp file in a folder just above the 'data' folder....
so C:\........\GT\data
The asp is located in the GT folder.
I get an internal error.
I'm calling it like this:
http://www.hurricanealley.net/GT/tes...80819T21:30:00

Any suggestions?

Well telling me what the internal error actually is might help.

My approach took the view that you had control over the receiver. Since you
haven't got control over that end you will need to tweak the approach to
generate the same XML structure the client end expected.

--
Anthony Jones - MVP ASP/ASP.NET
Aug 20 '08 #5
I'm not sure what the error is. I only see the resulting IE error page.
What is the best approach to debug? I'm only using a text editor.
Thanks!
Bryan
--
Thanks!
Bryan
"Anthony Jones" wrote:
"Bryan" <Br***@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
Anthony,
I've put the asp file in a folder just above the 'data' folder....
so C:\........\GT\data
The asp is located in the GT folder.
I get an internal error.
I'm calling it like this:
http://www.hurricanealley.net/GT/tes...80819T21:30:00

Any suggestions?


Well telling me what the internal error actually is might help.

My approach took the view that you had control over the receiver. Since you
haven't got control over that end you will need to tweak the approach to
generate the same XML structure the client end expected.

--
Anthony Jones - MVP ASP/ASP.NET
Aug 20 '08 #6
"Bryan" <Br***@discussions.microsoft.comwrote in message
news:78**********************************@microsof t.com...
I'm not sure what the error is. I only see the resulting IE error page.
What is the best approach to debug? I'm only using a text editor.

In IIS manager click on the application then in the Features View pane
double click 'ASP' in the IIS section.

Expand the Debugging Properties and change 'Send Errors To Browser' to True

Now IIS will send more info to the browser.
--
Anthony Jones - MVP ASP/ASP.NET
Aug 20 '08 #7


"Bryan" wrote:
I'm not sure what the error is. I only see the resulting IE error page.
Also, fix your browser!

If using MSIE:
-- Click on TOOLS menu
-- Click on INTERNET OPTIONS menu item
-- Click on ADVANCED tab
-- *UN*check "Show friendly HTTP error messages"
-- OK

Now you should get more useful error output.
Aug 20 '08 #8
It's not a big deal, but there's really no need for an INDENT function.

VBScript has the built-in SPACE function, already.

So calling
Space(iTreeLevel)
is 100% equivalent to your
indent(iTreeLevel)
and, of course, somewhat faster.
Aug 20 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: 'perch | last post by:
I'm trying to tweak the Google toolbar search button to do two things; to include selected text as a string search (i.e. as though I'd entered the text in ""), and to open a new page for the search...
3
by: Jane D | last post by:
I have got a bookmarklet for use with Opera which highlights all occurrences of some text in the displayed page. I find it very useful. Sometimes I need to use two or three different colours...
0
by: Josué Maldonado | last post by:
Hello list I use postgresql ODBC driver (Version 7.03.02) to access the database (7.3.4) running on RH8, the connection string is:...
1
by: Christopher W. Douglas | last post by:
I am building a VB.NET application in Visual Studio.NET 2003. I have an existing project with code and forms I want to reuse in this project. If I am copying a module file, then Add Existing Item...
1
by: CR1 | last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to...
7
by: Jon | last post by:
Hello all, I've been doing some performance analysis on our app, and I've discovered that the below code is quite a bottle neck: this.OnFillParameters(selectCommand); SqlDataAdapter...
1
by: capdownlondon | last post by:
Im using the following code to duplicate a record varCnt(retrieved from a combo box on the form) many times, and it only duplicates the record with the fields present on the form for that record....
4
by: DGS | last post by:
Hi all... Yesterday I asked about setting a cookie with an intially requested URL that could be used later. I found the code to do it. For the code on the login.html page I would like to tweak...
2
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I have some code (given to me), but I don't know alot about ASP, so I was hoping someone here can help. The code below will scan a folder and subfolder with a date/time input and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.