Public void downloadfile (string filedatapath, string timepath, string filename)
{
VaR content = string. empty;
Byte [] filecontent = NULL;
VaR success = false;
If (string. isnullorwhitespace (filedatapath) | string. isnullorwhitespace (filename) | string. isnullorwhitespace (timepath ))
{
Content = "parameter error ";
}
Else
{
VaR filelist = movie service. getaskfilelistbyuserid (cvidendity. username. tolower ());
If (filelist. Contains (filename ))
{
Filename = filename. insert (filename. lastindexof ("."), String. Format ("_ {0}", timepath ));
String filepath = string. Format (@ "{0} {1} \ {2} \ {3}", appdomain. currentdomain. basedirectory, filedatapath, timepath, filename );
If (system. Io. file. exists (filepath ))
{
Success = true;
Filecontent = system. Io. file. readallbytes (filepath );
}
Else
{
Content = "the file doesn' t exist ";
}
}
Else
{
Content = "no permission ";
}
}
Response. Clear ();
Response. Buffer = true;
Response. contentencoding = system. Text. encoding. getencoding ("UTF-8 ");
If (SUCCESS)
{
Response. contenttype = "application/vnd. MS-excel ";
Response. appendheader ("content-disposition", "attachment; filename =" + filename + "");
Response. binarywrite (filecontent );
}
Else
{
Response. contenttype = "text/html ";
Response. Write (content );
}
Response. Flush ();
Response. End ();
}