当我第一次打开文件、读取其内容并保存时,该应用程序运行良好。但是当我再次打开同一个文件时,我得到一个file-not-found exception。如何刷新流?
FileStream usrFs = null;
try
{
usrFs = new FileStream(xmlSource, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite);
}
catch (IOException)
{
MessageBox.Show("File not found in the specified path");
}
XML
<?xml version="1.0"?>
<MenuItem BasePath="c:\SampleApplication">
堆栈跟踪
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at SampleApplication.MainForm.ProcessDocument(BackgroundWorker worker, DoWorkEventArgs e) in C:\Users\273714\Desktop\CRAFTLite - VSTS\SampleApplication\MainForm.cs:line 179