Server Error in '/' Application.

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Source Error:


Line 33:             DirectoryInfo di = new DirectoryInfo(Server.MapPath("~") + "/Gallery");
Line 34:             if (!di.Exists) di.Create();
Line 35:             DirectoryInfo[] dis = Request.QueryString["gname"] == null ? di.GetDirectories() : di.GetDirectories(Request.QueryString["gname"]);
Line 36:             foreach (DirectoryInfo di2 in dis)
Line 37:             {

Source File: d:\hostingspaces\xpl.ir\ninja-sport.ir\Gallery.aspx.cs    Line: 35

Stack Trace:


[PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.]
   System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) +14553544
   System.IO.Path.InternalGetDirectoryName(String path) +164
   System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost) +312
   System.IO.DirectoryInfo.InternalGetDirectories(String searchPattern, SearchOption searchOption) +93
   Gallery.Page_Load(Object sender, EventArgs e) in d:\hostingspaces\xpl.ir\ninja-sport.ir\Gallery.aspx.cs:35
   System.Web.UI.Control.OnLoad(EventArgs e) +108
   System.Web.UI.Control.LoadRecursive() +90
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1533


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0