parsing - Are there any multipart/form-data parser in C# - (NO ASP) -
i trying write multipart parser things getting complicated , want ask if knows of ready parser in c#!
just make clear, writing own "tiny" http server , need pars multipart form-data too!
thanks in advance, gohlool
i open-sourced c# http form parser here.
this more flexible other 1 mentioned on codeplex, since can use both multipart , non-multipart form-data
, , gives other form parameters formatted in dictionary
object.
this can used follows:
non-multipart
public void login(stream stream) { string username = null; string password = null; httpcontentparser parser = new httpcontentparser(stream); if (parser.success) { username = httputility.urldecode(parser.parameters["username"]); password = httputility.urldecode(parser.parameters["password"]); } }
multipart
public void upload(stream stream) { httpmultipartparser parser = new httpmultipartparser(stream, "image"); if (parser.success) { string user = httputility.urldecode(parser.parameters["user"]); string title = httputility.urldecode(parser.parameters["title"]); // save file somewhere file.writeallbytes(file_path + title + file_ext, parser.filecontents); } }
Comments
Post a Comment