inspu Posted May 30, 2011 Share Posted May 30, 2011 Hi I am creating a log file.And i need date and time should be append with the file name.I tried as follows but not working. ; Show current local time $tCur = _Date_Time_GetLocalTime() $tCur1 = _Date_Time_SystemTimeToDateTimeStr($tCur) MsgBox(0, "Timevalue", _Date_Time_SystemTimeToDateTimeStr($tCur)) $file = FileOpen($tCur1+".txt", 1) I am getting the value in MsgBox.But file name is not creating.Can anyone help me. Link to comment Share on other sites More sharing options...
JoHanatCent Posted May 30, 2011 Share Posted May 30, 2011 Hi I am creating a log file.And i need date and time should be append with the file name.I tried as follows but not working. ; Show current local time $tCur = _Date_Time_GetLocalTime() $tCur1 = _Date_Time_SystemTimeToDateTimeStr($tCur) MsgBox(0, "Timevalue", _Date_Time_SystemTimeToDateTimeStr($tCur)) $file = FileOpen($tCur1+".txt", 1)I am getting the value in MsgBox.But file name is not creating.Can anyone help me.Try with option 9. See help for detail. $file = FileOpen($tCur1+".txt", 9) Link to comment Share on other sites More sharing options...
inspu Posted May 30, 2011 Author Share Posted May 30, 2011 Sorry this didnt work for me... Moreover i didnt see option 9 in help file Link to comment Share on other sites More sharing options...
sleepydvdr Posted May 30, 2011 Share Posted May 30, 2011 Without more of your code, I can't be sure this will work, but I think it will: $tCur = _Date_Time_GetLocalTime() $tCur1 = _Date_Time_SystemTimeToDateTimeStr($tCur) MsgBox(0, "Timevalue", _Date_Time_SystemTimeToDateTimeStr($tCur)) FileCopy("", @scriptdir & "\" & $tCur1+".txt", 8) ; <-- the 8 creates a blank file $file = FileOpen(@scriptdir & "\" & $tCur1+".txt", 1) FileWrite($file, _Date_Time_SystemTimeToDateTimeStr($tCur)) #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
inspu Posted May 30, 2011 Author Share Posted May 30, 2011 I think i cinfused all. I need a file name with date and time. Eg:"testReport05/30/2011.txt" I dont want to write date and time into the file.File name should have date and time. Link to comment Share on other sites More sharing options...
JoHanatCent Posted May 30, 2011 Share Posted May 30, 2011 (edited) I think i cinfused all. I need a file name with date and time. Eg:"testReport05/30/2011.txt" I dont want to write date and time into the file.File name should have date and time. inspu - "/" and ":" will be illegal characters for a file name. Also 9 was a combo of 1 = Append and 8 = Create the file structure. You can try: #Include <Date.au3> $tCur = _Date_Time_GetLocalTime() $tCur1 = _Date_Time_SystemTimeToDateTimeStr($tCur) $tCur1 = StringReplace( $tCur1, "/","_") $tCur1 = StringReplace( $tCur1, ":","_") MsgBox(0, "Timevalue", $tCur1 ) $file = FileOpen($tCur1&".txt", 9) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file , $tCur1) FileClose($file) ShellExecute($tCur1&".txt") You can also investigate _FileWriteLog Edited May 30, 2011 by JoHanatCent Link to comment Share on other sites More sharing options...
inspu Posted May 30, 2011 Author Share Posted May 30, 2011 Thanks This is working Link to comment Share on other sites More sharing options...
JoHanatCent Posted May 30, 2011 Share Posted May 30, 2011 Thanks This is workingYou're welCome. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now