You might know this situation: You are trying to open a file which is locked by another process. In .NET, an IOException handles this situation. But what to offer the user then? One solution is to create and open a copy of the document. The following code shows how to create a copy of the file using a FileStream in order to load this into TextControl.
private void OpenFileAsCopy() { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Office Open XML|*.docx|Microsoft Word|*.doc"; if (openFileDialog1.ShowDialog() != DialogResult.OK) return; FileStream fsLockedFile = new FileStream( openFileDialog1.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); TXTextControl.StreamType streamType = openFileDialog1.FileName.EndsWith("docx") ? TXTextControl.StreamType.WordprocessingML : TXTextControl.StreamType.MSWord; textControl1.Load(fsLockedFile, streamType); fsLockedFile.Close(); }