mcjimbo
asked on
Getting this function to work in ASP.NET VB?
Hi guys,
I wrote this function in ASP to get the and display the modified date of a file.
<%
Function getLastModified()
Dim strFile
Dim File,oFile
Dim dtmLMod
Dim dtmLModDate
strFile = Request.ServerVariables("S CRIPT_NAME ")
strFile = Replace(strFile, "/", "\")
strFile = Server.MapPath(strFile)
Set File = Server.CreateObject("Scrip ting.FileS ystemObjec t")
Set oFile = File.GetFile(strFile)
dtmLMod = oFile.DateLastModified
Set oFile = Nothing
Set File = Nothing
dtmLModDate = FormatDateTime(dtmLMod, 1)
getLastModified = dtmLModDate
End Function
%>
I thought it might be .NET compatible, so I did the following:
<script language="VB" runat="server">
Function getLastModified()
Dim strFile
Dim File,oFile
Dim dtmLMod
Dim dtmLModDate
strFile = Request.ServerVariables("S CRIPT_NAME ")
strFile = Replace(strFile, "/", "\")
strFile = Server.MapPath(strFile)
Set File = Server.CreateObject("Scrip ting.FileS ystemObjec t")
Set oFile = File.GetFile(strFile)
dtmLMod = oFile.DateLastModified
Set oFile = Nothing
Set File = Nothing
dtmLModDate = FormatDateTime(dtmLMod, 1)
getLastModified = dtmLModDate
End Function
</script>
However i'm getting the followin error message:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30807: 'Let' and 'Set' assignment statements are no longer supported.
Source Error:
Line 13: strFile = Server.MapPath(strFile)
Line 14:
Line 15: Set File = Server.CreateObject("Scrip ting.FileS ystemObjec t")
Line 16:
Line 17: Set oFile = File.GetFile(strFile)
Can anyone shed any light on what I need to change to make this script work in .net?
Thanks in advance
James
I wrote this function in ASP to get the and display the modified date of a file.
<%
Function getLastModified()
Dim strFile
Dim File,oFile
Dim dtmLMod
Dim dtmLModDate
strFile = Request.ServerVariables("S
strFile = Replace(strFile, "/", "\")
strFile = Server.MapPath(strFile)
Set File = Server.CreateObject("Scrip
Set oFile = File.GetFile(strFile)
dtmLMod = oFile.DateLastModified
Set oFile = Nothing
Set File = Nothing
dtmLModDate = FormatDateTime(dtmLMod, 1)
getLastModified = dtmLModDate
End Function
%>
I thought it might be .NET compatible, so I did the following:
<script language="VB" runat="server">
Function getLastModified()
Dim strFile
Dim File,oFile
Dim dtmLMod
Dim dtmLModDate
strFile = Request.ServerVariables("S
strFile = Replace(strFile, "/", "\")
strFile = Server.MapPath(strFile)
Set File = Server.CreateObject("Scrip
Set oFile = File.GetFile(strFile)
dtmLMod = oFile.DateLastModified
Set oFile = Nothing
Set File = Nothing
dtmLModDate = FormatDateTime(dtmLMod, 1)
getLastModified = dtmLModDate
End Function
</script>
However i'm getting the followin error message:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30807: 'Let' and 'Set' assignment statements are no longer supported.
Source Error:
Line 13: strFile = Server.MapPath(strFile)
Line 14:
Line 15: Set File = Server.CreateObject("Scrip
Line 16:
Line 17: Set oFile = File.GetFile(strFile)
Can anyone shed any light on what I need to change to make this script work in .net?
Thanks in advance
James
Hi Try This
Dim File= Server.CreateObject("Scrip ting.FileS ystemObjec t")
If File.FileExists(strFile) Then
oFile = File.GetFile(strFile)
dtmLMod= oFile.DateLastModified
End if
Set is no longer supported
cheers
Len
Dim File= Server.CreateObject("Scrip
If File.FileExists(strFile) Then
oFile = File.GetFile(strFile)
dtmLMod= oFile.DateLastModified
End if
Set is no longer supported
cheers
Len
ASKER
Nope, didn't work. It must be said i'm a newbie to .net so if someone could walk me through this i'd appreciate it.
Thanks again
James
Thanks again
James
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just in case you don't find the answer you're looking for here in the ASP forum, you can try posting this question in the ASP.NET forum:
https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/
Good luck!
peh803