Well, I'm not sure if its a good practise, or if there are any better classes to achieve this goal.
But I often use an XmlResolver (wich is the abstract type, or the concrete version is the XmlUrlResolver) to get a stream to any file or uri alike without the fuss of handling http requests etc.
Just use the XmlResolver function like this:
XmlUrlResolver resolver = new XmlUrlResolver();
using (Stream stream = resolver.GetEntity(new Uri(filename), string.Empty, typeof(Stream)))
{
//do stuff with the file
}
This saves gives you a lot of extra flexibility in terms of where you can put your files. Eg some files can now come over FTP or HTTP.
On a lighter note, I scheduled my Workflow Foundation MCTS exam. Wish me luck.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment