Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am trying to get a download dialogbox i keep getting the error that says Value cannot be null.Parameter name: path1
I don't understand please help.

This is the code that's giving me the error
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Configuration;



namespace New
{
    public partial class DownloadFile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString.Get("ID") != null)
            {
                Response.Clear();
                Guid ID = new Guid(Request.QueryString.Get("ID"));
                BLL.FileSave myFile = new BLL.FileSave();


                Response.ContentType = "application/x-uknown";
                Response.AppendHeader("Content_Disposition", "attachment; fileName=\"" + myFile.originalName + "\"");


                if (myFile.containsFile)
                {
                    Response.BinaryWrite(myFile.fileData);
                }
                else
                {
//the error is here
                    Response.WriteFile(Path.Combine(Bll.AppConfiguration.UploadsFolder, myFile.fileUrl));
               }

            }
        }
    }
}
Posted
Updated 12-Sep-11 0:58am
v3
Comments
Herman<T>.Instance 12-Sep-11 6:57am    
you instantiate:
<pre lang="c#">BLL.FileSave myFile = new BLL.FileSave();</pre>
How you know the myFile.originalName?

what are the value for:
Bll.AppConfiguration.UploadsFolder, myFile.fileUrl?
anupkulkarni85 12-Sep-11 7:19am    
check the path of the file
Elina Blank 12-Sep-11 11:51am    
"myFile.originalName" does not seem to have value. And this is the error you get.

Try and debug your code to find out where this error occurs.
Ensure that all mandatory values you need to pass into the dialog are not null.
 
Share this answer
 
You did not provide any fragment of code with the identifier "path1". It is not possible to get an "error" and do not see on what line this error was generated; it's not possible to expect an answer not even indicating the kind of "error": compile-time, run-time exceptions, or what?

A help could only be provided to a person who can really formulate a problem and able to get help.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900