In that process, the loop store three files at a time (loop time).
The write log process is
Create the text file in the Try statement
In the loop:
a. download file 1 on 3
b. WriteLine Download "
c. go back to a for file 2 on 3
d. WriteLine Download "
e. go back to a for file 3 on 3
f. WriteLine Download "
g. back to the start of the loop
h. Close the Try statement.
The question I am asking (you and me) is:
Isnt it better to:
a. create the log file
b. close the log file
In the download loop:
c. Save the image 1 on 3
d. Open the log file (and set the Try bloack)
e. Append the text log line
f. Close the text log line
g. Close the Try block
h. Close the Save file 1 on 3
and so on for the other 2 download files.
Back to the start of the Loop.
Why do I ask ?
That annoy me to think the Try block holds my (nearly) whole code. But must I think at these kind of things ?
That what was worried me, but I could not wrote it.
On the other hand, if the application / computer hang, in the other process I keep a track of what have been saved (done).Other question: what good keeping track of this can be ?
I keep the code part that ( where it originally was and still is):
a. create the log folder
b. create an empty log file (Using BinaryStream):
Log_Name = "Log - " + ReplaceAll(Log_Date.SQLDateTime, “:”, “-”) + “.txt”
Then:
c. I created a method to append several information for each download item (file name, file size, ordered (and selected) Headers and the header block (.Source). [this in a Try block).
To make the log readable, I added an intro line, a, b and c entries and some empty lines.
d. I noticed that the file length (I get from the FolderItem used to store the downloaded item) is empty, most of the time. So I add .Flush before closing the BinaryStream: now I have my item size.
e. Close the TextOutputStream.
At last, the log file will take size on the hard disk, but since no one cares