The Clipper "DIRECTORY()" command used to display the date a folder (in those far-off days still called a Directory...) was created. Now it returns the date modified instead. Is there any way to get back to the creation date? Windows7 defaults to changing the folder modification date whenever one of the files within it changes: arguably one of the most stupid things even Micrsoft could have dreamed up. A bit like saying my car has been modified any time any of the passengers change, but don't get me started on Microsoft stupidities...)
Templar
Directory function
Moderator: Rathinagiri
Re: Directory function
Hi Templar,Templar wrote: ↑Fri Apr 06, 2018 10:46 am The Clipper "DIRECTORY()" command used to display the date a folder (in those far-off days still called a Directory...) was created. Now it returns the date modified instead. Is there any way to get back to the creation date? Windows7 defaults to changing the folder modification date whenever one of the files within it changes: arguably one of the most stupid things even Micrsoft could have dreamed up. A bit like saying my car has been modified any time any of the passengers change, but don't get me started on Microsoft stupidities...)
Yes, it is possible.
There is the function FileStats() in the Harbour contrib library XHB.
Please take a look for a simple sample below:
Code: Select all
#include "minigui.ch"
//***************************************************************************
PROCEDURE Main
DEFINE WINDOW wMain ;
AT 100,200 WIDTH 230 HEIGHT 100 ;
TITLE "Demo" ;
MAIN ;
NOMAXIMIZE NOSIZE
DEFINE BUTTON btOpen
ROW 10
COL 20
WIDTH 80
HEIGHT 50
CAPTION 'Get Stats'
ACTION OpenFile()
END BUTTON
DEFINE BUTTON btClose
ROW 10
COL 120
WIDTH 80
HEIGHT 50
CAPTION 'Close'
ACTION wMain.Release
END BUTTON
END WINDOW
ACTIVATE WINDOW wMain
RETURN
//***************************************************************************
PROCEDURE OpenFile()
LOCAL cTxt := ""
LOCAL cFileName := "DEMO.PRG"
LOCAL cFileAttr , nFileSize
LOCAL dCreateDate, nCreateTime
LOCAL dChangeDate, nChangeTime
FileStats( cFileName, @cFileAttr , @nFileSize , ;
@dCreateDate, @nCreateTime, ;
@dChangeDate, @nChangeTime )
cTxt += "File Name : " + cFileName + CRLF
cTxt += "Attributes: " + cFileAttr + CRLF
cTxt += "File Size : " + xChar( nFileSize ) + CRLF
cTxt += "Created : " + xChar( dCreateDate ) + " - " + TString( nCreateTime ) + CRLF
cTxt += "Changed : " + xChar( dChangeDate ) + " - " + TString( nChangeTime )
MsgInfo( cTxt, "File statistiscs" )
RETURN
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Directory function
Thanks Grigory! Very usefull!!
Serge
Serge
There's nothing you can do that can't be done...
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Directory function
One small notice: file has to exist else you will get an RTE!
Serge
Serge
There's nothing you can do that can't be done...
Re: Directory function
Hello Drigory
Thanks for that. Looks useful. I have not yet got into the other library functions, so maybe I will have to start on that. It looks like being a big project though!
Templar
Thanks for that. Looks useful. I have not yet got into the other library functions, so maybe I will have to start on that. It looks like being a big project though!
Templar