c# Exception The process cannot access the file

前端 未结 5 1674
孤独总比滥情好
孤独总比滥情好 2021-01-13 15:21

I\'m getting an exception: The process cannot access the file.

Here\'s the code:

if (!Monitor.TryEnter(lockObject))
    return;
try
{
    watcher.Ena         


        
5条回答
  •  误落风尘
    2021-01-13 15:36

    In your try block you have opened the file. You need to close it.

    XmlDocument xdoc = new XmlDocument();
    xdoc.Load(FileName);
    

    Follow this example.

    http://msdn.microsoft.com/en-us/library/zcsyk915.aspx

提交回复
热议问题