2011-08-06 10 views

Répondre

2

Je pense que votre solution est:

Response.ContentType = "application/ms-excel"; 
Response.AddHeader("content-disposition", "attachment; filename=CSVhhID" + Uid + ".csv"); 
string newpath2 = System.Web.HttpContext.Current.Server.MapPath("~//downloadfile//CSVID" + Uid + ".csv"); 
FileStream sourceFile = new FileStream(newpath2, FileMode.Open); 
long FileSize; 
FileSize = sourceFile.Length; 
byte[] getContent = new byte[(int)FileSize]; 
sourceFile.Read(getContent, 0, (int)sourceFile.Length); 
sourceFile.Close(); 
+0

ça marche aussi ..... –

2

Utilisez cette technique.

string filePath = Server.MapPath("~/files/myFileName.csv"); 
    System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath); 
    Response.ContentType = "application/octet-stream"; 
    Response.AddHeader("Content-Disposition", string.Format("attachment;filename=\\\"{0}\\\"", filePath)); 
    Response.AddHeader("Content-Length", fileInfo.Length.ToString()); 
    Response.WriteFile(filePath); 
    Response.End(); 
+1

Merci beaucoup Govind ... Merci –

Questions connexes