Help with DateLastAccessed property

He has: 183 posts

Joined: Nov 2003

I can get this script to work when i have selected the file path and file. but, i want to add the file path and then the file name comes from a database.

this is the DatlastAccessed script:

<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile("c:\test.txt")
Response.Write("File last accessed on: ")
Response.Write(f.DateLastAccessed)
set f=nothing
set fs=nothing
%>
'

and this is where i get the file name from:
<%=(Recordset1.Fields.Item("FILENAME").Value)%>'

I have tried to add the recordset field to the datelastaccessed script but i get this error:

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/CoursePages/YourPersonal_MoreDetails.asp, line 204

set fb=fsb.GetFile("D:/webspace/schoolsintra.net/wwwroot/Uploader/UploadedFiles/<%=(Recordset1.Fields.Item("FilePath").Value)
------------------------------------------------------------------------------------------------------------^

It would be great if someone and shine a light on why this is not working. Cheers

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

set f=fs.GetFile(server.mappath("\uploader\uploadedfiles\" & Recordset1.Fields("filepath") & "\" & Recordset1.Fields("filename") )
'
assuming;
"\uploader\uploadedfiles\" is the path in the site where the files are and filepath & filename are in the database.

the error in your code is probably due to a script delimiter "<%" inside a script and a shorthand response.write "=" where it should probably be a concatenation "&"

so this ... UploadedFiles/<%=(Recordset1.Fields.Item("FilePath") ...should be

... UploadedFiles/" & (Recordset1.Fields.Item("FilePath") ...

BTW there is no need to write out Recordset1.Fields.Item("FILENAME").Value each time

In the recordset collection,

Value is the default of item
Item is the default of fields
Fields is the default of Recordset

so it can be written as
Recordset1.Fields.Item("FILENAME") or
Recordset1.Fields("FILENAME") or
Recordset1("FILENAME")

And all would be equally correct

Chris

Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples

He has: 183 posts

Joined: Nov 2003

Cheers for that... I will try it later on, and tell you what i have done (if it works or not)

He has: 183 posts

Joined: Nov 2003

Hi, I'm still having problems with this one line:

set f=fs.GetFile(server.mappath("../Uploader/UploadedFiles/" & Recordset1.Fields("FilePath")  )'

I keep geting this error message and i can not resolve it.

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

set f=fs.GetFile(server.mappath("../Uploader/UploadedFiles/" & Recordset1.Fields("FilePath") ")
------------------------------------------------------------------------------------------------^

I have tried to remove the ") at the end, kept only the ) and it still dont work.

Any ideas?

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

it should be "))" at the end.
one to close server.mappath and one to close GetFile

He has: 183 posts

Joined: Nov 2003

set f=fs.GetFile("set f=fs.GetFile(server.mappath("\SchoolsIntranet\Uploader\UploadedFiles\" & Recordset1.Fields("FilePath") "))"'

It doesnt like me at all... I may of ending the code wrong, but ever event that i do it still shows an error at this point ("FilePath").

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

lose both of the last quotes They were only in my post as seperators

... ("filepath")))

He has: 183 posts

Joined: Nov 2003

Hi,

I still get this error:

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/CoursePages/YourPersonal_MoreDetails.asp, line 204

set f=fs.GetFile("set f=fs.GetFile(server.mappath("\SchoolsIntranet\Uploader\UploadedFiles\" & Recordset1.Fields("FilePath")))
------------------------------------------------------------------------------------------------------------------^

I know its not the Recordset Field because it works fine as

<?php
=(Recordset1.Fields.Item("FilePath").Value)
?>

Also just so that you know by "FilePath" is not the main path to the file, it is just the file name. That is why i have the "\SchoolsIntranet\Uploader\UploaderFiles\"

Any ideas? Cheers

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

Look at the error carefully.

you will that now you have an extra bit of code

set f=fs.GetFile("

at the beginning

errors are not always what they say.

Chris

Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples

He has: 183 posts

Joined: Nov 2003

Well if you look at that..... Didnt even see that and guess what, IT WORKS!!!

Cheers for all your help

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.