J
Jayme Pechan
I seem to have run into a strange problem. I'm hoping one of you understand
the inner working of the file IO better than I and could explain why I'm
seeing what I am. Basically, I have a log folder where I append to text
files frequently. Every 10 minutes or so, I check to see if the files are
greater than a certain size and then archive them. After archiving the
files, I use the File.Delete function to delete each of the files. I put
the File.Delete in a lock section to ensure that it completes before another
threat attempts to write to them. The problem I'm seeing is that it seems
like the File.Delete doesn't delete the files immediately and even though it
is supposed to remove it from the directory tree (I think), if another
thread attempts to append to one of these files too soon after leaving my
lock block, the whole program locks up. I thought of putting in a sleep
after the deletions but I wouldn't know how long to set it for.
My solution is to move the files to a sub folder first before deleting them
but wanted to see if anyone would know why I'm having this problem in the
first place.
Thanks
Jayme
the inner working of the file IO better than I and could explain why I'm
seeing what I am. Basically, I have a log folder where I append to text
files frequently. Every 10 minutes or so, I check to see if the files are
greater than a certain size and then archive them. After archiving the
files, I use the File.Delete function to delete each of the files. I put
the File.Delete in a lock section to ensure that it completes before another
threat attempts to write to them. The problem I'm seeing is that it seems
like the File.Delete doesn't delete the files immediately and even though it
is supposed to remove it from the directory tree (I think), if another
thread attempts to append to one of these files too soon after leaving my
lock block, the whole program locks up. I thought of putting in a sleep
after the deletions but I wouldn't know how long to set it for.
My solution is to move the files to a sub folder first before deleting them
but wanted to see if anyone would know why I'm having this problem in the
first place.
Thanks
Jayme