Created RTF when try to open RTF, got an error
After create RTF, try to open, got an error "Word experienced an error trying to open the file".
I have C# class that generate RTF code and savve to RTF by stores RTF code in StringBuilder and using the following code to write text as a file:
StreamWriter SW = null;
SW = File.CreateText(filepath);
SW.WriteLine(rtfCode); //string pass from StringBuilder
catch (Exception ex)
if(SW != null)
The problem is I have a class to open RTF file w/ MS Word to open RTF file right away after save, sometime I'd get this error:
"Word experienced an error trying to open the file.
Try these suggestions.
* Check the file permissions for the document or drive.
* Make sure there is sufficient free memory and disk space.
* Open the file with the Text Recovery converter. "
But when I open that folder and double click same file, I can open it just fine. I did some search on google but not found much.
1. Is that mean file still in use even after I run "GC.Collect();..." command?
2. If yes, how can I check file in use or clear it from memory?
3. The RTF file need to be open right after save. Is there anyway I can work around this?
Any suggestion is welcome. Thanks.