The process cannot access file ... being used by another process
Author: MikeCaron
Creation Date: 3/16/2009 11:34 AM
profile picture

MikeCaron

#1
I could not find a previous topic on this error message, "The process cannot access the file 'c:\tmp\crdt1.txt' because it is being used by another process."

Seems to be some sort of a file synchronization/flushing issue when parsing 839 symbols using the Multisymbol backtest function on EOD data. About 221 unique symbols are being written out to the file. I do a flush of the StreamWriter object, but not the FileStream object.

Any thoughts on how to resolve this problem?


CODE:
Please log in to see this code.
profile picture

DaveAronow

#2
Try wrapping the file access in a using block. Google it for more info.
profile picture

MikeCaron

#3
It took some hunting, but thanks for the clue Dave! I am posting the fix in case anyone else stumbles across this problem. It appears that the StreamWriter() call was returning an error. Waiting until it no longer has an error fixed the problem.

CODE:
Please log in to see this code.
profile picture

TrendCatcher

#4
Hi Mike,
Could you repost the entire script? Thanks.
profile picture

MikeCaron

#5
Here is the updated script:

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).