Borje

[ SOLVED ] Need help with FileGetTime and FileSetTime

8 posts in this topic

#1 ·  Posted (edited)

Hi everybody !!

;Please if anybody could help me whit this!!

;What is wrong with this code ?

;What i want is filegetTime from test1.txt and test2.txt then compare this and if it differnts Then
;fileset time on both files in the code below.


;IF $fil1 = $fil2 Then
; ok()                                                     
; notok()
;EndIf     

;Down here is my little code

#include <file.au3>
#include <array.au3>

$drive = "c:"


If Not @error Then
 $t =  FileGetTime(@ScriptDir & "\test1.txt",1)                ; [1 = Created] , 2 = Used
 $fil1 = $t[0] & "-" & $t[1] & "-" & $t[2]
 endif
 $u =  FileGetTime(@ScriptDir & "\test2.txt",1)                ; [1 = created] , 2 = Använd
 $fil2 = $u[0] & "-" & $u[1] & "-" & $u[2]


MsgBox(0, "Files     ",$fil1 & "        "& $fil2)

$var1 = FileSetTime(@ScriptDir & "\test1.txt", "20171010",1)   ; [1 = Created]       , 2 = Used
$var2 = FileSetTime(@ScriptDir & "\test2.txt", "20171010",1)

Exit


 
; Down here is my error message

;$fil1 = $t[0] & "-" & $t[1] & "-" & $t[2]
;$fil1 = $t^ ERROR
;>Exit code: 1    Time: 0.329

 

Edited by Borje

Share this post


Link to post
Share on other sites



#2 ·  Posted

@Borje in the future please put your code in code tags <>, makes it much easier to read ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

Just now, JLogan3o13 said:

@Borje in the future please put your code in code tags <>, makes it much easier to read ;)

Ok how i do that ?

Share this post


Link to post
Share on other sites

#4 ·  Posted

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted

I have a another Question if i use fileinstall to example @Scriptdir and after that try to change the creation date on the file with

FileSetTime that would not works to give the new date but if I run from editor not compiled that works but when i compiled

that not works why?  perhaps there is a solution of this problem?

 

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

That is because your variable "t" is not an array. In other words, you couldn't get the creation time of "test1.txt". Make sure that:

  1. The text document is in the same folder with your au3
  2. Use --> FileGetTime("test1.txt",1) -- instead of script directory
  3. Write the full path to your file

TY.

Share this post


Link to post
Share on other sites

#7 ·  Posted

Thanks taylansan

I should test this and see if that works.

Share this post


Link to post
Share on other sites

#8 ·  Posted

Hi taylansan

 

I have now test your example an all works problem was that you told me t is not an array

Thanks again

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now