File occupancy exception occurs when loading file

SyntaxEditor for WPF Forum

Posted 3 years ago by Sunshine - Appeon
Version: 22.1.0
Avatar

Exception picture: http://ibb.co/LNCWmx2

I would like to ask if Document writes to the file during LoadFile. If it is only read, why does the file occupation problem occur? Our current scenario is that when the external file changes, our Editor will automatically reload the file, and then this problem occurs

Comments (1)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The LoadFile method is effectively doing this:

using (StreamReader reader = File.OpenText(path)) {
	text = reader.ReadToEnd();
}

I believe File.OpenText just opens the file read-only, so I'm not sure why it would trigger that error.  You could try running that code directly and you should see the same thing.


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.