Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting System Date and Time Programitically
Message
De
20/12/2017 04:28:40
 
 
À
19/12/2017 12:42:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01656542
Message ID:
01656582
Vues:
79
this happens to me when I remove the battery from my camera. the date of creation is automatically set to 1 January 5 years back.i must readjust it on the interface each time when work with it....
if not adjusted,I do it after the fact on the photos (date creation).
this is an exhaustive functions and links turning around file dates (creation,last modicication,last acceession).
1)*last modified date of a file with aDir
local m.lcfilename,m.gnbre
m.lcfilename=getfile()
if empty(m.lcfilename)
return .f.
endi
m.gnbre=adir(gabase,m.lcfilename)
messagebox("Last modified date of "+m.lcfilename+":"+dtoc(gabase(1,3))+" time:"+gabase(1,4))

2.set library to home(1)+"foxtools"
foxtouch(getfile(), 2017, 12, 19, 12, 00, 00)  &&this is an undocumented function in help and anywhere !!
set library to

but can see this utility touch in :https://www.codeproject.com/Articles/3258/Touch-for-Windows
touch is originally an unix function ported on windows.

3.Fdate() function :Returns the last modification Date or DateTime for a file.
See in foxhelp:
FDATE(cFileName [, nType])

Ftime() function :return the modification time for a file.
FTIME(cFileName

LUPDATE():Returns the date on which a table was last updated.
LUPDATE([nWorkArea | cTableAlias])


4.visit news2news site
HOWTO: Use the Win32 API to Access File Dates and Times
http://www.news2news.com/vfp/index.php?example=177
http://www.news2news.com/vfp/index.php?example=399  &&change creation date time for a folder--just create a new folder and put it all files you want to change the date & time (2 parameters in function are folder and date time you want) and run the code.the folder and all the containede files date creation are updated with you given dateTime). 

or
http://www.news2news.com/vfp/index.php?example=65   (locked,this is for members only).


5.return date created,last modified,last accessed of any file
local m.lcFilename
lcFilename=getfile()
if empty(m.lcfilename)
return .f.
endi
local m.oFSo,m.oFile
	m.oFSO = CreateObject("Scripting.FileSystemObject")
	m.oFile =oFSO.GetFile(m.lcFilename)
    local m.myvar
	text to m.myvar textmerge noshow
     -File:<<m.lcfilename>>	
	 "Date created       ="  << oFile.DateCreated >>
	 "Date Last modified =" << oFile.DateLastModified >>
	 "Date last Accessed =" << oFile.DateLastAccessed >>
	endtext
	_cliptext=m.myvar
	messagebox(m.myvar,0+32+4096,"In clipboard")
	oFile = Null
	oFSO = Null


6. change the last-modified date of a file
local m.lcfilename
m.lcfilename=getfile()
 if empty(m.lcfilename)
 return .f.
 endi
 local oshell,oFolderItem
 oShell =NewObject("Shell.Application")
 oFolder = oShell.NameSpace(justpath(m.lcfilename))
 oFolderItem = oFolder.ParseName(justfname(m.lcfilename))
 oFolderItem.ModifyDate =  ttoc(dateTime())   &&actual dateTime
 objFolder=null
 oshell=null
 *explorer/rightclick on the file pointed and see properties


7.can see SetFileTime function in msdn: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724933(v=vs.85).aspx


8.Nirsoft to the rescue: try the freeware tool nircmd. It's a bunch of useful tools in one small command line program. One of the commands allows you to specify either
* or both of created time and modified time, like this:
    nircmd.exe setfiletime "c:\temp\myfile.txt" "24-06-2003 17:57:11" "22-11-2005 10:21:56"
	download free nircmd at http://www.nirsoft.net/

9. COPY FILE FileName1 TO FileName2   &&changes the date creation of filename1 to current datetime() in filename2

10. 
there is many utilities to changes file dates (creation,lastmodified,last acceessed) for ex  :https://www.wikihow.com/Change-File-Dates
	
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform