|
| |
|
|
yogaboy
Posts: 377 Joined: 5/22/2004 Status: offline
|
Document management - 11/17/2005 8:00:52
Does anyone know of any good sites with stuff about document management? What I want is to hide the source of the doc, hide urls, stream it to the client etc etc. I'm looking for big-picture stuff, I'm not worried about the languge, I'll be writing it in c#, but I'm most interested in the concepts - so that when I start coding there's not an important aspect I've not thought about/planned for. Any help is much appreciated.
|
|
|
|
yogaboy
Posts: 377 Joined: 5/22/2004 Status: offline
|
RE: Document management - 11/17/2005 19:20:31
Thanks Bobby, looks very similar to the one on the link - that's helpful, means I have to think less! Here's what I've come up with, possibly a few holes but I'm certainly no expert on VB to C# (or even just c#!)
private void Page_Load(object sender, System.EventArgs e)
{
//put an if block around SendFile2Stream to satisfy your auth levels
//pass the querystring with the filename to the method
SendFile2Stream(Request.QueryString[0]);
}
//method for sending the file to the output stream
private void SendFile2Stream(string filename)
{
//declare local variables
FileStream fs = null;
byte [] bytBytes = null;
//try block
try
{
//open the filestream to the document
//note" Configuration.WebsiteDocsPath is a class-property I've got to get useful keys from the
//web.config
fs = new FileStream(Configuration.WebsiteDocsPath + filename, FileMode.Open, FileAccess.Read);
//create a byte array of doc's length
bytBytes = new byte[fs.Length];
//read the filestream into the array
fs.Read( bytBytes, 0, Convert.ToInt32( fs.Length ) );
}
//should be some catch blocks here!!!
//don't cross the streams! :)
finally
{
fs.Close();
}
//add the headers
Response.AddHeader( "Content-disposition", "attachment; filename=" + filename );
//pick a content type
Response.ContentType = "application/octet-stream";
//write the doc to the output stream
Response.BinaryWrite(bytBytes);
//end
Response.End();
}//end method
It worked for me so far...but I didn't add any exceptions yet as I'm sure there are lots and lots for the file/stream objects and I don't want to mislead anyone by leaving them out/just using the general exception. I also left out the authorization "if", as that can be sorted out according to one's own fascist desires (I've got a few of those).
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|