c# - What's wrong when 'the requested operation cannot be performed on a file with a user-mapped section open?' -


I am developing an application that is reading and writing a certain file on disk (but synchronously) However, how large the file is, the more I receive the following IOException:

The requested operation can not be performed on a file that opens a user-mapped section.

is being done from:

  system. IO error .__ error Virus (System32.If., Int32 rights, Boolean useRights, fileshare share, Int32 BufferSize, FileOptions option, SECURITY_ATTRIBUTES secAttrs, string msgPath, Boolean bFromProxy) on System.IO.FileStream..ctor (string path, FileMode mode, using FileAccess , fileshare share, Int32 BufferSize, FileOptions option) SystemkIOkStreamWriterkCreateFile (string path System.IO.StreamWriter..ctor on System.IO.StreamWriter..ctor, boolean append) (string path, Boolean attached, encoding Encoding, int32 bufferSize (string path, boolean append, encoding encoding) on ​​System.IO.File.WriteAllText (string path, st Ring Co ntents, Encoding encoding) System.Windows.Forms.Control.OnClick (EventArgs e) at System.Windows.Forms.Button.OnClick (EventArgs e) at System.Windows.Forms.Button.OnMouseUp (MouseEventArgs mevent) system . In WindowskFormskControlkWmMouseUp (Message & amp; m) (message System.Windows.Forms.Button.WndProc & amp; m) (message System.Windows.Forms.ButtonBase.WndProc & amp; M , MouseButtons button, Int32 clicks System.Windows.Forms.Control.WndProc (message & amp); m) in System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr hWnd; System.Windows.Forms.Control.ControlNativeWindow. System.indo.form at WndProc (Message & amp; System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Me on Message & Interpretation), Interpreted Media, Interpetrip Liparum). UNICEFANETNET Medips On Dispatches Messageway (MSG & MMS) systems. Windows .form. Applications. Comptant Manager System. Windows .form. UnisonFinitive Memoirs. Comptant Manager FUPM Message Loop (Int 32 Dv Component IDID, Int32 Cause System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner on Int32 pvLoopData) (Int32 Reasoning ApplicationContext Reference) System.Windows.Forms.Application.ThreadContext.RunMessageLoop (Int32 due to ApplicationContext reference) in S.Forms.Application.Run (Form mainForm) TestApp.Program.Main () on System.Window  

as you can see, with the exception of the File.WriteAllText < / Is removed from within the code>. I suspect that this exception was to be done together with reading and writing, so tried to limit access to the file. Instead of pausing them both a lock and a mutex seemed to increase the number of exceptions. So what's really going on? What exactly does this exception mean and how can it be stopped?

I open a file (open, loop (writes), but after a mistake, The call was repeated ... so I ended up "The requested operation can not be done on a file that opens a user mapped section." Okay, I removed the second call and then the problem was resolved. It seems that two (open / closed) (open / closed) rats are also happening soon on the same file, and this is due to some ... some developers suggest calling GC. Check to shut down each I / O operation correctly. Not to complete (open, loop (writes), closed) Very soon It seems that when an operation is complete, the second request comes and it throws the problem.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -