c# - Console.Writeline throws “Not enough storage is available to process this command.” IO exception -


i have application copy 1000 files 1 folder another. after each file copied write copy success/failure information separate file.

at time, during writing copy information in file, streamwriter.writeline throws following exception:

10/28/2014 12.21.02.068 message : not enough storage available process command. filename : copying file c:\program files\xyz\samplefile.xml c:\program files\abc\samplefile.xml.xml | inner exception : | type : system.io.ioexception | source : mscorlib

not enough storage available process command.  @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.__consolestream.write(byte[] buffer, int32 offset, int32 count) @ system.io.streamwriter.flush(boolean flushstream, boolean flushencoder) @ system.io.streamwriter.write(char[] buffer, int32 index, int32 count)    @ system.io.textwriter.writeline(string value)    @ system.io.textwriter.synctextwriter.writeline(string value)    @ system.console.writeline(string value)    @ versionactivator.versionactivationcontroller.logmessage(string message)                             mscorlib : not enough storage available process command.** 

but application works fine when pc initialized in safe mode.

my code :

foreach (fileinfo fi in source.getfiles()) {     if (fi.exists)     {         string destfilename = path.combine(target.fullname, fi.name);          // if file readonly, make non-readonly         if (file.exists(destfilename))         {              file.setattributes(destfilename, fileattributes.normal); // ims 2793051209         }         logmessage(string.format("copying file {0} {1}", fi.fullname, destfilename));         fi.copyto(destfilename, true);     } }  public void logmessage(string message) {     try     {         **console.writeline(message); // place getting io exception**         if (m_logwriter != null)         {             m_logwriter.writeline(               string.format(@"{0} {1}"               , datetime.now.tostring("mm/dd/yyyy hh.mm.ss.fff")               , message)             );         }     }     catch (exception ex)     {         writeexception(ex, message);               throw;     } } 


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -