ioexception


StreamWriter.Writeline throws “Not enough storage is available to process this command.” IO exception


I have an application which will copy 1000 files from One folder to another. After each file is copied we will write the Copy Success/Failure information into a separate file. At some time, during writing this copy information in a file, StreamWriter,WriteLine throws the following exception"
10/28/2014 12.21.02.068 Message : Not enough storage is available to process this command.
Filename : Copying file C:\Program Files\XYZ\SampleFile.xml to C:\Program
Files\ABC\SampleFile.xml.xml | Inner Exception : | Type : System.IO.IOException | Source : mscorlib
Not enough storage is available to process this command.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__ConsoleStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.WriteLine(String value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(String value)
at System.Console.WriteLine(String value)
at VersionActivator.VersionActivationController.LogMessage(String message)
mscorlib : Not enough storage is available to process this command.**
But this application works fine when the PC initialized in safe mode.
Can any one please help me?
It is developed in C#.
My code is
private void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
try
{
if (!source.Exists)
{
LogMessage(string.Format("{0} does not exist!", source.FullName));
return;
}
// Check if the target directory exists, if not, create it.
if (Directory.Exists(target.FullName) == false)
{
Directory.CreateDirectory(target.FullName);
}
// Copy each file into it's new directory.
foreach (FileInfo fi in source.GetFiles())
{
if (fi.Exists)
{
string destFileName = Path.Combine(target.FullName, fi.Name);
// If the file is readonly, make it non-readonly
if (File.Exists(destFileName))
{
File.SetAttributes(destFileName, FileAttributes.Normal); // IMS 2793051209
}
LogMessage(string.Format("Copying file {0} to {1}", fi.FullName, destFileName));
fi.CopyTo(destFileName, true);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.ToString());
throw;
}
}
public void LogMessage(string message)
{
try
{
Console.WriteLine(message);
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;
}
}
And the m_LogWriter will be initialized at Windows_load event.
if (m_LogWriter != null)
return;
DirectoryInfo logFolder = new DirectoryInfo(versionActivatorConfigObj.Folders.LogFolder.Path);
try
{
if(!(logFolder.Exists))
{
logFolder.Create();
}
logFolder.Refresh();
if(logFolder.Exists)
{
string logFileName = string.Format(#"MyCopyLog{0}.txt", DateTime.Now.ToString("M-d-yyyy_h-m-s"));
m_LogWriter = new StreamWriter(Path.Combine(logFolder.FullName, logFileName), true);
m_LogWriter.AutoFlush = true;
}
}

Related Links

java.io.IOException: Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured
How to cancel request using merge
PrintWriter doesn't seem to be writing to file even though I'm closing it
StreamWriter.Writeline throws “Not enough storage is available to process this command.” IO exception
IO Exception in OSMembrane while executing pipeline
Exception in thread Main Error java.lang.numberformat.exception
java.io.IOException: The filename, directory name, or volume label syntax is incorrect Error while writing to HTTP directory

Categories

HOME
rust
artificial-intelligence
user-interface
class
automapper
add-on
message-queue
dafny
whmcs
openlayers-3
semantic-web
mathematical-optimization
dependencies
swift2
flurry
phpmqtt
minecraft
tfs2010
anchor
azure-logic-apps
lc3
lapack
bundler
corona
scheduled-tasks
bazaar
activeadmin
unordered-multimap
prompt
hdmi
gravity-forms-plugin
math.js
sendmessage
spring-annotations
laravel-4.2
openbr
autodesk-model-derivative
plantuml
stackpanel
variable-variables
assert
google-now
stat
right-click
plane
raytracing
1wire
vungle-ads
morphline
nomad
ssi
lightning-workbench
subforms
android-sharing
wikimapia
word-2016
ltrace
cefpython
msg
between
android-sdcard
static-methods
meld
maximize
currency-exchange-rates
servicestack-bsd
phpquery
bayesglm
miniconda
nette
srv-record
auto-generate
unhandled
compositetype
componentart
fuseesb
mxe
subview
html-escape-characters
fiware-bosun
mod-auth-openidc
n-tier-architecture
igor
webmethod
redpitaya
xmi
pre
nosql-aggregation
meteorite
autonumber
boinc
form-for
ldif
chartfx
mongo-jackson-mapper
tfs-sdk
ip-geolocation
stretch
image-scanner
algol68
boost-foreach
data-dump
asp.net-mvc-views
principles
stretchblt

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App