Is there a way to touch a file (i.e. change its modification time) from a JScript? There is a DateLastModified property in FileSystemObject (ActiveXObject开发者_StackOverflow社区), but it's read-only.
Couldn't even find a clear "no, you can't" on this...
The Shell object (Shell.Application) provides the read-write ModifyDate property for files. Here's an example of how you can use it:
var oShell = new ActiveXObject("Shell.Application");
var oFolder = oShell.NameSpace("C:\\MyFolder");
var oFile = oFolder.ParseName("MyFile.txt");
oFile.ModifyDate = "11/11/2009 8:00:00 AM";
See also the Hey, Scripting Guy! article on the subject: Using the Shell Object to Modify File Dates in VBScript. (The sample code there is in VBScript, but it should help you get the idea.)
加载中,请稍侯......
精彩评论