gesto
Posts: 42
|
| Posted: 06/17/2005, 5:17 AM |
|
does anyone now how can i show on the page when the file (.asp) was created and modified??
|
 |
 |
smalloy
Posts: 107
|
| Posted: 06/17/2005, 3:25 PM |
|
Well, I’m not sure about how to use a CC function to get the information that you want but I do know that this is within the ASP Text Stream Object.
Here is what the code would look like
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim strPathInfo, strPhysicalPath
Get the path of the file that you need the info for, just change the filename to the asp page
strPathInfo = Request.QueryString(filename)
strPhysicalPath = server.MapPath(strPathInfo)
Dim objFSO, objFile
SET objFSO = CreateObject(Scripting.FileSystemObject)
SET objFile = objFSO.GetFile(strPhysicalPath)
Now here is the info you can get, like file size, last modified, date created, etc.
Dim intFileSize, dteLastModified, dteCreated, dteLastAccessed
intFileSize = objFile.size
dteLastModified = objFile.DateLastModified
dteCreated = objFile.DateCreated
dteLastAccessed = objFile.DateLastAccessed
Now you could fill a CodeChage label with
Mygrid.label1.Value = dteLastModified
Finally, Add Double Quotes around your filename and Scripting.FileSystemObject, i.e. "mypage.asp", I have comments in the code to help expalin whats going on, just add a single quote to them.
I hope this helps,
Steve
_________________
Anything can be done, just give me time and money. |
 |
 |
gesto
Posts: 42
|
| Posted: 06/20/2005, 4:24 AM |
|
hi steve!
thanks for your help, but I have just another question: will I have to add the name of the file always, or can I get by coding the name of the page where the code above is placed?
|
 |
 |
smalloy
Posts: 107
|
| Posted: 06/20/2005, 11:30 AM |
|
If this is something that you need for more than one page I recommend making this page an include file and passing the page name as a variable. Set the whole code to a function, i.e. Funtion GetLastModified() - code then End Function
The page name (and path) is kept in the ASP Server Variables collection, specifically the script_name. You can delete the:
strPathInfo = Request.QueryString(filename)
strPhysicalPath = server.MapPath(strPathInfo) and replace it with:
strPhysicalPath = Request.ServerVariables("script_name")
Then, in the before show of your label set the value to:
form.label.Value = GetLastModified()
So you never have to hard code a page name!
If you ever just need the page name, you strip it out of the full path like this:
'This whole part strips the full path and gives you just the page name
Dim textlength
Dim nonslashtext
textlength = Len(Request.ServerVariables("script_name"))
nonslashtext = textlength - 1
strModified = (Right(Request.ServerVariables("script_name"),nonslashtext))
Steve
_________________
Anything can be done, just give me time and money. |
 |
 |
|