locked
Parameter Invalid!? RRS feed

  • Question

  • User592294478 posted

    For the following code, can someone please tell me what is invalid about the parameter that is passed?

    // get path for 'no thumbnail' image if you want one
    String sNoThumbPath = Server.MapPath("~/images/nothumb.jpg");

     

    // map requested path
    try
    {
    path =
    string.Format(@"M:\web\users\FileRepository\{0}.file", int.Parse(Request.QueryString["id"]));
    }
    catch
    {
    path = sNoThumbPath;
    }

    Bitmap thumbBitmap;

    try
    {
    Trace.Warn(
    "Page", string.Format("Trying path: {0}", path));
    thumbBitmap =
    new Bitmap(path);
    }
    catch
    {
    Trace.Warn(
    "Page", string.Format("Says that {0} is not valid", path));
    Trace.Warn(
    "Page", string.Format("Trying {0} instead", sNoThumbPath));
    thumbBitmap =
    new Bitmap(sNoThumbPath);                                              <------ Getting the error here...
    }

    produces this:

    Exception Details: System.ArgumentException: Parameter is not valid.

    Stack Trace:

    [ArgumentException: Parameter is not valid.]
       System.Drawing.Bitmap..ctor(String filename) +393925
       Michael_thumbnails.Page_Load(Object sender, EventArgs e) in m:\web\users\intranet\Michael\thumbnails.aspx.cs:61
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
    

    The files exist, verified it several times over. You tell me... we'll all know...

    Tuesday, September 2, 2008 3:05 PM

Answers

  • User187056398 posted

    You'll get that message if the filename or path does not exist (it's really a bad error message).

    The files exist, verified it several times over.

    You could try this to be sure:

            if (File.Exists(sNoThumbPath) == false)
                Response.Write("File Name/Path is bad");
            else
                thumbBitmap = new Bitmap(sNoThumbPath);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 2, 2008 3:14 PM

All replies

  • User187056398 posted

    You'll get that message if the filename or path does not exist (it's really a bad error message).

    The files exist, verified it several times over.

    You could try this to be sure:

            if (File.Exists(sNoThumbPath) == false)
                Response.Write("File Name/Path is bad");
            else
                thumbBitmap = new Bitmap(sNoThumbPath);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 2, 2008 3:14 PM
  • User592294478 posted

    ok, time to be [:$]

    nothumbs.jpg is what I have in my code... but nothumbs.gif is the name of the file on the server...

    Tuesday after long weekend = Monday in reality

    Is it 5:00 yet?

    MB

    Tuesday, September 2, 2008 4:53 PM