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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

READING THE DATE OF A FILE ... 1

Status
Not open for further replies.

mac4511

Technical User
Apr 26, 2001
14
GB
Hi there I need to read the date of text / csv file dynamically to place it on a web page which uses databinding. It has to work in IE 4 / 5.0 / 5.5. not NS.

I can do the data binding part from the csv file OK, but I need to add the last modified date of that csv file which was used to generate the page.

Does anyone have any ideas how I could do this. I don't think that the databinding feature in IE4 or IE5 etc allows for this, so maybe its just a javascript thing I need to do as an extra.

It has to run locally , as the databinding runs locally on a machine not always web connected. The update of the file concerned is done via web overnight, hence need to read latest date of the file.

I guess even VBscript would do if theres a way - I am open to offers !.

Thanks in advance
mac

 


Mac4511

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("YourFilename")
ModDate = f.DateLastModified

Cheers!
Fengshui1998
 
Hi Fengshui,

Thanks for the reply...I amvery poor at VBScript at the moment its been a long time since I did any. Can I ask a big favour.
Could you shouw me the full script for this section please,
from <SCRIPT to </SCRIPT> not sure if it should be a function or Sub

for example, the file I need to see the date of is

c.csv
which would be at the same level as the web page containing this script page.

I just need to see the structure and the method of showing the date value within HTML. I assume its something like <INPUT=text VALUE= (value from VBSCRIPT routine)

If you could help it would be most appreciated.
Thanks
Mac
 
Hi,

Why not go with:
<!-- #flastmod file=&quot;./file.xls&quot; -->
of course this has to be used in a file with a shtml extension. If your page is an html file, no problem just change it to shtml. If you file is an asp page then you can use the #flastmod in it, but you can use #flastmod in a separate shtml file and then include that shtml in your asp page with a #include.

Bye.
 
Here an example...

<HTML>
<!--...-->
<script language=&quot;vbscript&quot;>
function getDateLastMod(pathtofile)
set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
set File=fso.GetFile(pathtofile)
getDateLastMod=File.DateLastModified
end function
</script>

<script language=&quot;vbscript&quot;>
'...
path=&quot;c:\c.csv&quot;
msgbox getDateLastMod(path)
'...
</script>

<script language=&quot;javascript&quot;>
'...
var path=&quot;c:\\c.csv&quot;;
alert(getDateLastMod(path));
'...
</script>

<!--...-->
</HTML>

________

George
 
Hi everyone,

Thanks to all your advice I now have a result I can live with.
One final tweak I could do with is to be able to make the path to the file being queried relative to the document which asks for its date.

For example, with using databinding I dont have to put the full path in to access the data, just &quot;c.csv&quot; is enough because the two files are in the same folder, which makes it all portable.

But with fso(GetFile) I have to put the whole path in which means I have to alter the whole path in the script if i move the pair of files. Is there a way around this?

thanks
Mac
 
U could use if u are in ASP Server.MapPath. This will return the entire path of your file if is in your web...

path=Server.MapPath(&quot;c1.csv&quot;)
msgbox getDateLastMod(path)


________

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top