Binary Write in

Probably you have seen a lot of websites which have download facilities. You can give the link of the file in your site which can be a threat for your site because, the user can be able to know where have you put the file.Then what can be the solution?

You can use BINARYWRITE in which will solve the above problem. Here is the  code for BinaryWrite

FileStream MyFileStream = new FileStream(@”d:\inetpub\wwwroot\Afile.pdf”, FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
Response.AddHeader( “content-disposition”,”attachment; filename=AnotherPdf.PDF”);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s