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("SCRIPT_NAME")
    strFile = Replace(strFile, "/", "\")
    strFile = Server.MapPath(strFile)

    Set File = Server.CreateObject("Scripting.FileSystemObject")

    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("SCRIPT_NAME")
    strFile = Replace(strFile, "/", "\")
    strFile = Server.MapPath(strFile)

    Set File = Server.CreateObject("Scripting.FileSystemObject")

    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("Scripting.FileSystemObject")
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
mcjimboAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peh803Commented:
James:

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:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/

Good luck!
peh803
0
lengreenCommented:
Hi Try This

Dim File= Server.CreateObject("Scripting.FileSystemObject")
If File.FileExists(strFile) Then
  oFile = File.GetFile(strFile)
  dtmLMod= oFile.DateLastModified
End if

Set is no longer supported

cheers

Len
0
mcjimboAuthor Commented:
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
0
lengreenCommented:
<script language="VB" runat="server">

response.write(getLastModified().toshortdatestring)
   
Function getLastModified() As DateTime
            Dim strFile
            Dim oFile
            Dim dtmLMod
            Dim dtmLModDate

            strFile = Request.ServerVariables("SCRIPT_NAME")
            strFile = Replace(strFile, "/", "\")
            strFile = Server.MapPath(strFile)

            Dim File = Server.CreateObject("Scripting.FileSystemObject")
            If File.FileExists(strFile) Then
                  oFile = File.GetFile(strFile)
                  dtmLMod = oFile.DateLastModified
            End If
            oFile = Nothing
            File = Nothing

            dtmLModDate = FormatDateTime(dtmLMod, 1)

            getLastModified = dtmLModDate
      End Function
</script>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.