 <p>You should not use MapPath() twice for the same path.</p> <p>Old Code:</p> <pre><code>System.IO.Directory.CreateDirectory(MapPath(path)); //Create directory if it doesn't exist </code></pre> <p>Corrected Code:</p> <pre><code>System.IO.Directory.CreateDirectory(path); //Create directory if it doesn't exist </code></pre> <p><strong>EDIT:</strong> Also corrected this: </p> <pre><code>string imgPath = path + "/" + imgName; </code></pre> <p>To this:</p> <pre><code>string imgPath = Path.Combine(path, imgName); </code></pre> <p><strong>whole corrected code:</strong></p> <pre><code> //get the file name of the posted image string imgName = image.FileName.ToString(); String path = Server.MapPath("~/ImageStorage");//Path //Check if directory exist if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); //Create directory if it doesn't exist } //sets the image path string imgPath = Path.Combine(path, imgName); //get the size in bytes that int imgSize = image.PostedFile.ContentLength; if (image.PostedFile != null) { if (image.PostedFile.ContentLength &gt; 0)//Check if image is greater than 5MB { //Save image to the Folder image.SaveAs(imgPath); } } </code></pre>