Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File System Object - last modified

Status
Not open for further replies.

siris

Programmer
Aug 13, 2004
10
IN
I'm using the following code to find out whether a file exists or not

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

If objFSO.FileExists(someFile) Then
response.write("File Exists")
End If

But after that I want to know when was it last modified. But is there any inbuilt function which will tell me that. Somebody told me that it's 'DateLastModified'. So I used objFSO.DateLastModified(someFile) to get the date. But it's not working. Is it the properway to use it or is there some other way.

Thanks.
 
siris,

datelastmodified is under the File object

so it would look like this:

(date of some sort)= file.datelastmodified

aaron
 
So aaron, how can I set the file object. Can I say

someFile.dateLastModified because someFile is just a variable. Or how can I change that to a real file??
 
Hope this gives u an idea...

function ShowFileAccessInfo(filespec)
{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filespec);//this is the important line
then u could get what u need from the file
s = filespec.toUpperCase() + &quot;<br>&quot;;
s += &quot;Created: &quot; + f.DateCreated + &quot;<br>&quot;;
s += &quot;Last Accessed: &quot; + f.DateLastAccessed + &quot;<br>&quot;;
s += &quot;Last Modified: &quot; + f.DateLastModified;
return(s);
}
[VBScript]
Function ShowFileAccessInfo(filespec)
Dim fso, f, s
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f = fso.GetFile(filespec)
s = UCase(filespec) & &quot;<BR>&quot;
s = s & &quot;Created: &quot; & f.DateCreated & &quot;<BR>&quot;
s = s & &quot;Last Accessed: &quot; & f.DateLastAccessed & &quot;<BR>&quot;
s = s & &quot;Last Modified: &quot; & f.DateLastModified
ShowFileAccessInfo = s
End Function
________
George, M
email : shaddow11_ro@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top