Question: i need to put a corporate site under a cms, which i haven't finally chosen yet, and have some tight requirements for it:

1. it should be very well organized at a code level, as i'm a developer and i need to add some very custom functionality to the site;
2. ability to create custom content types (a la drupal's cck does);
3. very good i18n abilities as the site will be multilingual to and fro;
4. caching / performance control solutions as the site experiences tens of thousands unique hosts a day;
5. publishing features like pre-moderation, authoring and versioning;
6. sending custom emails;
7. creating custom web forms with input data validation;
8. content access levels;
9. i would like to have my static content (images / css / pdf's etc) on a separate domain (possibly hosted on amazon cloud) processed by caching proxy server like nginx -- not a tight requirement, but still;

i evaluated these requirements and came up with ez publish as a solution. i'm not very experienced in cms world; i've worked with drupal and wordpress, but, being good cms'es, none of these meet my requirements (drupal isn't good at a code level and wordpress is a blog solution). also i don't want to mess with joomla or complexity of typo3. so, my question is -- does ez publish have a competitor in this field, regardless of the implemention language?

Answer: 
I have just refactored a bit the code and now it works (on my machine):

```
private static void CreateThumbnail(string[] b, double wid, double hght, bool Isprint)
{
    string saveAt = "D:\\check";
    foreach (string path in b)
    {
        var directory = new DirectoryInfo(path);
        string outputPath = Path.Combine(saveAt, directory.Name);
        foreach (FileInfo f in directory.GetFiles("*.*", SearchOption.AllDirectories))
        {
            if (f.DirectoryName != directory.FullName)
            {
                outputPath = Path.Combine(saveAt, directory.Name, f.Directory.Name);
            }
            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            using (Image imagesize = Image.FromFile(f.FullName))
            using (Bitmap bitmapNew = new Bitmap(imagesize))
            {
                double maxWidth = wid;
                double maxHeight = hght;
                int w = imagesize.Width;
                int h = imagesize.Height;
                // Longest and shortest dimension 
                int longestDimension = (w > h) ? w : h;
                int shortestDimension = (w < h) ? w : h;
                // propotionality  
                float factor = ((float)longestDimension) / shortestDimension;
                // default width is greater than height    
                double newWidth = maxWidth;
                double newHeight = maxWidth / factor;
                // if height greater than width recalculate  
                if (w < h)
                {
                    newWidth = maxHeight / factor;
                    newHeight = maxHeight;
                }

                string fileName = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(f.Name) + ".jpeg");
                bitmapNew.GetThumbnailImage((int)newWidth, (int)newHeight, () => false, IntPtr.Zero)
                    .Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }
    }
}

```

I have to say few things about your old code: 

* use `foreach` when possible;
* avoid the first three lines, they are useless;
* avoid unused variables;
* keep your code as clean as possible;
About the "GDI+ generic error" and the "Out Of Memory" exceptions, you should take a look at that link on SO: [What is the "best" way to create a thumbnail using ASP.NET?](https://stackoverflow.com/questions/27921/what-is-the-best-way-to-create-a-thumbnail-using-asp-net)

You must use the C# `using` statement to make sure unmanaged GDI+ resources underneath the .NET surface are freed as quickly as possible to avoid out of memory errors.

The GDI+ generic can happen if the image cannot be converted for example.