Ejemplo n.º 1
0
 public void Run(ResponeCode code, FileInfo file, bool fileoption = false)
 {
     try
     {
         HeaderOption option = HeaderOption.Create();
         if (fileoption)
         {
             option.AddOption("Content-Type", "multipart/formed-data");
             option.AddOption("Content-Disposition", "attachment; filename=" + file.Name);
             option.AddOption("Length", file.Length.ToString());
         }
         else
         {
             option.AddOption("Content-Type", "text/html");
         }
         byte[] header = BuildHeader(code, option);
         client.Send(header);
         if (file != null && file.Exists)
         {
             byte[] data = GetFile(file);
             client.Send(data);
         }
     }
     catch (Exception e)
     {
         LastException = e;
         client.Send(BuildHeader(ResponeCode.CODE500));
     }
     finally
     {
         client.Close();
     }
 }