Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 1372
Product
FileUpEE
Title
Cannot download file with "&" in the filename
Problem
When trying to download a file with "&" in the name (e.g. Test&Test.doc), the file does not download. The web server exception from the server response says: The system cannot find the file specified. Applies to FileUpPE and FileUpEE.
Solution

Note: Although this article discusses the issue in the context of FileUpEE, this information is also relevant to FileUpPE.

In the FileUpEE samples, the download page makes GET requests to the server that have the file name embedded as a parameter value in the request's query string. The query string is in the form of "?File=filename". When the request object is received by FileUpEE on the server in the DownloadFile() method, the Request.QueryString property is used to acccess the 'File' parameter:

(C#)
requestedFileName = Request.QueryString["File"];

The issue here is that the request query string delimitates parameters by the "&" character. For instance, "?name=Bob&?age=22" represents two separate parameters. This means that if the query string contains a "&", Request.QueryString will automatically treat the query string as though it has multiple parameters.

In the case of a document called "Test&Test.doc", it will perceive "Test" to be the first parameter. The requestedFileName variable is set to the "Test" and FileUpEE cannot find the file named "Test".

Although the samples use Request.QueryString["File"] to parse out the file name, there are other methods for extracting this information. Below is some code that detects whether there is a "&" in the file name and handles that scenario separately:

(C#)
string requestedFileName = "";
string queryString = Convert.ToString(Request.QueryString);

//query string will be in the form of: serverURL + "?File=" + filename
//Normally, "&" indicates multiple parameters in the query string
//DownloadFile() should only be receiving a single parameter: the file name
if (queryString.Contains("&"))
{
requestedFileName = queryString.Substring(queryString.IndexOf("?File=") + 6);
}
else
{
//Original 
requestedFileName = Request.QueryString["File"];
}

This converts the query string to a regular string and then extracts the file name from the query.

Having issues with other special characters?

Setting up FileUpEE and FileUpPE to support files with Unicode characters in the filenames
Cannot download file with "%" in the filename
Created : 3/28/2011 5:26:58 PM (last modified : 3/28/2011 5:26:57 PM)
Rate this article!
 
Comments