Hi,
My program first generate a text file, then read it and process it. The
problem of my current program is that, if running failed, that text file
generated last run will be read and processed.
I hope to check a check to see if the text file is newly generated. It
it is not, that means it is generated by previous run and current run
has failed. The program then stop and will not proceed to read that file.
Could you show me how to do this? Thank you very much.
rossum - 27 Sep 2007 22:52 GMT
>Hi,
>
[quoted text clipped - 7 lines]
>
>Could you show me how to do this? Thank you very much.
Create a file called myfile-new.txt.
Read it and process it.
Rename the file you have just read to myfile-old.txt
If the new file and the old file have different names then the program
will not pick up the old file when it looks for the new one.
rossum
GArlington - 28 Sep 2007 10:09 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>
> Could you show me how to do this? Thank you very much.
How about simple process the file -> delete or archive it? Then after
successful processing run there will be NO file to process, the new
file will ONLY appear AFTER successful generation run.
Is that too trivial?
www - 28 Sep 2007 13:15 GMT
> How about simple process the file -> delete or archive it? Then after
> successful processing run there will be NO file to process, the new
> file will ONLY appear AFTER successful generation run.
> Is that too trivial?
I cannot delete that file, because the file is one of the products I
need. What do you mean "archive it"? One reply suggested:
the program generates myfile_new.txt
the program read and process it
in the end, the program rename myfile_new.txt to myfile_old.txt
That is a reasonable way to achieve my purpose.
Another way suggested by another reply is:
I should set up my program in such a way: if the program fails to
generate that text file, through an exception, then the program will not
proceed to read the text file.
Thank you all for your replies. I greatly appreciate it.