Are you a cool kid who wants to impress your friends and family with your mad skillz? Check out the Kid's Corner for lots of fun, easy to understand lessons on programming!
Saturday, February 28, 2009
Wednesday, February 25, 2009
I was asked if I worked before on making a module to allow the users from downloading a document without the direct access to that document, the document (not just images) may be saved in SQL or on MOSS document library with no read access to the user.
Yes I worked before on file types like word files, but general files NO. and I give him the main idea of adding the document stream response and change the response content type.
And after a while I asked him about the output and he sends this code to me:
Yes I worked before on file types like word files, but general files NO. and I give him the main idea of adding the document stream response and change the response content type.
And after a while I asked him about the output and he sends this code to me:
System.IO.FileInfo fileInfo = new System.IO.FileInfo(@"C:\d\AhmedCV.doc");
System.IO.FileStream fl = fileInfo.OpenRead();
byte[] file = new byte[(int)fl.Length];
fl.Read(file, 0, (int)fl.Length);
fl.Close();
System.IO.MemoryStream mem = new System.IO.MemoryStream(file);
Response.Clear();
Response.ContentType = "application/x-unknown";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
mem.WriteTo(Response.OutputStream);
Response.End();
Subscribe to:
Posts (Atom)
Blessings of working on large real-world projects
Working on large real-world projects can offer numerous blessings and benefits, both professionally and personally. Here are some of the key...