Category archives for C#

File upload – simple multipart request stream parser, using Regex

(In case your text file contains line starting exactly with the “matched” ones below – simply adapt your Regex) private static List<string> fileUploadRequestParser(Stream stream) { //—————————–111111111111111 //Content-Disposition: form-data; name=”file”; filename=”data.txt” //Content-Type: text/plain //… //… //—————————–111111111111111 //Content-Disposition: form-data; name=”submit” //Submit //—————————–111111111111111– List<String> lstLines = new List<string>(); TextReader textReader = new StreamReader(stream); string sLine = textReader.ReadLine(); Regex […]