Guest User

rafale

a guest
Aug 21st, 2011
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. // get stream object from wcf service
  2. int fileid = 1;
  3. Stream wcfDownload = wcfFileService.Download(fileid);
  4.  
  5. public static void SimpleListenerExample(string prefix)
  6. {
  7.     string prefix =  "http://localhost:8080/index/";
  8.  
  9.     // Create a listener.
  10.     HttpListener listener = new HttpListener();
  11.    
  12.     // Add the prefixes.
  13.     listener.Prefixes.Add(prefix);
  14.     listener.Start();
  15.  
  16.     // Note: The GetContext method blocks while waiting for a request.
  17.     HttpListenerContext context = listener.GetContext();
  18.     HttpListenerRequest request = context.Request;
  19.    
  20.     // Obtain a response object.
  21.     HttpListenerResponse response = context.Response;
  22.    
  23.     // Construct a response.
  24.     byte[] buffer = System.Text.Encoding.UTF8.GetBytes(wcfDownload);
  25.     // Get a response stream and write the response to it.
  26.     response.ContentLength64 = buffer.Length;
  27.     System.IO.Stream output = response.OutputStream;
  28.     output.Write(buffer,0,buffer.Length);
  29.    
  30.     // Close output stream
  31.     output.Close();
  32.     listener.Stop();
  33. }
  34.  
  35. // Would this be the correct method of accessing the stream?
  36. MediaElement.Source = prefix; // at http://localhost:8080/index/
Advertisement
Add Comment
Please, Sign In to add comment