|
using System;
using System.IO;
using MiniHttpd;
namespace MiniHttpdApp
{
public class HelloWorldFile : IFile
{
public HelloWorldFile(string name, IDirectory parent)
{
this.name = name;
this.parent = parent;
}
string name;
IDirectory parent;
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
// Assign a MemoryStream to hold the response content.
request.Response.ResponseContent = new MemoryStream();
// Create a StreamWriter to which we can write some text, and write to it.
using(StreamWriter writer = new StreamWriter(request.Response.ResponseContent))
{
writer.WriteLine("Hello, world!");
}
}
public string ContentType
{
get { return ContentTypes.GetExtensionType(".txt"); }
}
public string Name
{
get { return name; }
}
public IDirectory Parent
{
get { return parent; }
}
#region IDisposable Members
public void Dispose()
{
// TODO: Add HelloWorldFile.Dispose implementation
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here