I am trying to download a folder that is on my drive C:/. My program doesn't show any error, it just doesn't work. I don't know what am I doing wrong, I think this folder name could be wrong? Or code? This is my code :
[HttpPost]
public HttpResponseMessage DownloadFile(DownloadInput input)
{
if (!string.IsNullOrEmpty(input.DosyaAdi))
{
string filePath = "C:/Uploads";
string fullPath = filePath + "/" + input.FileID + "/" + input.FileNm;
return CreateResponseFileContent(fullPath);
//string fullPath = AppDomain.CurrentDomain.BaseDirectory + filePath + "/" + input.SorunID + "/" + input.DosyaAdi;
}
return new HttpResponseMessage(HttpStatusCode.NotFound);
}
public HttpResponseMessage CreateResponseFileContent(string fullPath)
{
HttpResponseMessage result = null;
try
{
result = Request.CreateResponse(HttpStatusCode.OK);
var fileStream = new FileStream(fullPath, FileMode.Open);
result.Content = new StreamContent(fileStream);
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
result.Content.Headers.ContentDisposition.FileName = fullPath;
return result;
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.Gone);
}
}