ep file downlading problem

hello everyone ;

i have a problem about file downloading in EP 4.0 . the goal is user can upload file to a specific folder in sharepoint ,

and whenever you want you could download it … the file format is free . pdf. xls .txt. doc etc…

i am holding folder properties in a table . the code block is below:

_fileName = file;
filesize = WinAPI::fileSize(_fileName);

// response.clear();
response.contentType(this.getContentType(strExt));
response.addHeader(“Content-Disposition”,“attachment; filename=” + _fileName);
response.addHeader(“File-size”,strfmt("%1",fileSize));

binData = new BinData();
binData.loadFile(_fileName);
response.binaryWrite(binData.getVariant());
response.flush();
//response.end();

  • file means Pyschical Path

What is wrong with this code , when i try to link button which is Download … save dialog is opened but downloading is not successfully complete. especially txt file was very weird behaviour that was included some HTML content…

any idea ?

Thanks in advance…

Best Regards