Not enough storage is available to complete this operation
0http://msdn.microsoft.com/en-us/library/ms681382%28VS.85%29.aspx
- ERROR_OUTOFMEMORY 14 (0xE) – Not enough storage is available to complete this operation.
- http://stackoverflow.com/questions/2881419/not-enough-storage-is-available-to-complete-this-operation-program-or-storage-m
- http://social.msdn.microsoft.com/Forums/en/sqlce/thread/06f90b9c-9c19-499e-b016-c161949251bc
- http://msdn.microsoft.com/en-us/library/aa454885.aspx#effective_memory_storage_power_mgmt_wm5_topic2
- http://support.microsoft.com/kb/326164
Consider using System.IO.Path.Combine() instead of string concatenation
0http://dotnettipoftheday.org/tips/SystemIOPathCombine.aspx
Let’s review the following code for creating a file path:
public string GetFullPath(string fileName)
{
string folder = ConfigurationManager.AppSettings["MyFolder"];
return folder + fileName;
}
This code is prone to error. For example, when you set the folder setting, you have to remember to make sure it ends with a slash. To avoid such problems use Path.Combine() method which will ensure that the folder has ending slash:
public string GetFullPath(string filename)
{
string folder = ConfigurationManager.AppSettings["MyFolder"];
return Path.Combine(folder, filename);
}
Use Path.GetRandomFileName() or Path.GetTempFileName() when working with temp files
0http://dotnettipoftheday.org/tips/PathGetRandomFileName.aspx
Do not reinvent function for generating unique name for temporary files. Use one of the existing methods:
- System.IO.Path.GetTempFileName() – use this method if you want to create temporary file in user’s temp folder.
- System.IO.Path.GetRandomFileName() – use this method if you just want to generate unique file name.
?? operator (C#)
0http://dotnettipoftheday.org/tips/double_question_mark_operator_cs.aspx
The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand. For example:
int? x = null; ... // y = x, unless x is null, in which case y = -1. int y = x ?? -1;
The ?? operator also works with reference types:
//message = param, unless param is null //in which case message = "No message" string message = param ?? "No message";
Speed testing in .NET – System.Diagnostics.Stopwatch
0http://dotnettipoftheday.org/tips/system_diagnostics_stopwatch.aspx
System.Diagnostics.Stopwatch is a replacement for what most people probably do to identify the time spent on excecuting a method. The process usually goes something like: create a DateTime.Now value at the start and then subtract the ending DateTime.Now to get the TimeDuration value that elapsed.
As an alternative, the Stopwatch class was built using low-level API calls, with less overhead than other .NET methods. If the hardware and Windows version of the computer support a high-resolution performance counter, it will use this counter instead of the standard More >