Will a using clause close this stream?

后端 未结 5 1254
难免孤独
难免孤独 2020-12-20 10:55

I\'ve apparently worked myself into a bad coding habit. Here is an example of the code I\'ve been writing:

using(StreamReader sr = new StreamReader(File.Open         


        
5条回答
  •  自闭症患者
    2020-12-20 11:40

    Since this doesn't seem to be a coding issue, I'm going to put my syadmin hat on and offer a few suggestions.

    1. Virus scanner on either the client or server that's scanning the file as it's created.
    2. Windows opportunistic locking has a habit of screwing things up on network shares. I recall it being mostly an issue with multiple read/write clients with flat file databases, but caching could certainly explain your problem.
    3. Windows file open cache. I'm not sure if this is still a problem in Win2K or not, but FileMon would tell you.

    Edit: If you can catch it in the act from the server machine, then Sysinternal's Handle will tell you what has it open.

提交回复
热议问题