Page 1 of 1
file date and time - how to set
Posted: Fri Feb 21, 2020 8:50 am
by Otto
Hello,
Can someone please help me out with the command for how to set file date and time.
Best regards
Otto
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 11:31 am
by karinha
Master Otto, explain better what you need.
Regards, saludos.
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 11:48 am
by Otto
Hello João,
I want to copy files to a server.
The files on the server should have the same date time as the original file.
Thank you in advance
Otto
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 11:56 am
by Otto
Hello,
I think I found an example:
function setfiledate(cFile, dDate)
local hFile := FOpen( cFile, FO_READWRITE )
local aInfo
SET DATE FRENCH
SET CENTURY ON
SetFTime( hFile, "13:00:00", dDate )
// MsgInfo( "D o n e !" )
FClose( hFile )
return nil
I will test.
Best regards
Otto
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 11:58 am
by Otto
There is a sample here:
C:\fwh\samples\testfdat.prg
Best regards
Otto
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 12:11 pm
by karinha
Maybe... Go reporting.
Code: Select all
#include "FiveWin.ch"
#include 'common.ch'
#define SW_HIDE 0
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_RESTORE 9
//------------------------------------*
// Deritrizes de fazer copia ou mover *
//------------------------------------*
#define FO_MOVE 0x0001
#define FO_COPY 0x0002
#define FO_DELETE 0x0003
#define FO_RENAME 0x0004
#define FOF_MULTIDESTFILES 0x0001
#define FOF_CONFIRMMOUSE 0x0002
#define FOF_SILENT 0x0004 // don't create progress/report
#define FOF_RENAMEONCOLLISION 0x0008
#define FOF_NOCONFIRMATION 0x0010 // Don't prompt the user.
#define FOF_WANTMAPPINGHANDLE 0x0020 // Fill in SHFILEOPSTRUCT.hNameMappings
// Must be freed using SHFreeNameMappings
#define FOF_ALLOWUNDO 0x0040
#define FOF_FILESONLY 0x0080 // on *.*, do only files
#define FOF_SIMPLEPROGRESS 0x0100 // means don't show names of files
#define FOF_NOCONFIRMMKDIR 0x0200 // don't confirm making any needed dirs
#define FOF_NOERRORUI 0x0400 // don't put up error UI
#define FOF_NOCOPYSECURITYATTRIBS 0x0800 // dont copy NT file Security Attributes
#define FOF_NORECURSION 0x1000 // don't recurse into directories.
//----------------------------> Copia o arquivo
FUNCTION execopia( warq, warq1 )
warq1 := alltrim( warq1 )
RETURN SHFile( , FO_COPY , warq + Chr( 0 ) , warq1 )
Regards.
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 12:17 pm
by karinha
Go reporting...
Code: Select all
#include "FiveWin.ch"
FUNCTION Main()
local cBuffer := Space( 12800 )
local nBufSize := 12800
hSource := FOpen( "Arquivo Original" )
hTarget := FCreate( "Arquivo Copia" )
While ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0
FWrite( hTarget, cBuffer, nBytes )
SysRefresh()
End
FClose( hSource )
FClose( hTarget )
If File("Arquivo Copia")
...
Endif
Return nil
Regards.
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 12:29 pm
by karinha
Code: Select all
#include "FiveWin.ch"
FUNCTION Main()
LOCAL cDirServ, cDirLocal, cArquivo
cDirServ := "\x_Archivos\"
cDirLocal := "E:\"
cArquivo := "teste.txt"
__CopyFile( cDirLocal+cArquivo, cDirServ+cArquivo+"2" )
RETURN NIL
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 12:30 pm
by Otto
Hello João,
Thank you for your help.
I test with your code.
I map a drive on a web server with netDrive.
To synchronize data between my mod harbour web page and my desktop, I copy files like images, etc.
To keep traffic low, I would like to test it the file was changed (size, time, date) before I copy.
Best regards,
Otto
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 12:35 pm
by nageswaragunupudi
Mr. Otto.
This is the simplest and reliable function from (x)Harbour.
Code: Select all
SetFDaTi( cFileName, dDate, cTime ) --> lSuccess
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 12:49 pm
by karinha
Master Rao, can you explain these commands please? I didn't find documentation.
Code: Select all
FileAttr()
FileDate()
FileTime()
SetFAttr()
SetFDaTi()
Many thanks.
Regards.
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 12:52 pm
by karinha
Re: file date and time - how to set
Posted: Fri Feb 21, 2020 7:33 pm
by Otto
Hello,
I did some more tests, but it seems as you can't change date/time stamp on these through netDrive3 (
http://www.netdrive.net) mapped drives.
It is interesting that if I upload a file to my webserver - I have the same time setup as on the local server - I have a time difference of 1 hour.
Maybe this has to do with summertime.
I do some more tests.
Best regards
Otto