c# - How to use TransmitFile with HttpListener -


i have http server written using httplistener , want zero-copy technology sending files clients.

is there option use transmitfile respond?

i assume you're referring httpresponse.transmitfile? httplistener doesn't buffer response content, need write directly output stream.

you can use extension method mimic asp.net behavior:

public static void transmitfile(this httplistenerresponse response, string filename) {     using (var filestream = file.openread(filename))     {         response.contentlength64 = filestream.length;         filestream.copyto(response.outputstream);     } } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -