public static function ServeFile($File, $Name = '', $MimeType = '', $ServeMode = 'attachment') {
      
      $FileIsLocal = (substr($File, 0, 4) == 'http') ? FALSE : TRUE;
      $FileAvailable = ($FileIsLocal) ? is_readable($File) : TRUE;
      
      if ($FileAvailable) {
         // Close the database connection
         Gdn::Database()->CloseConnection();
         
         // Determine if Path extension should be appended to Name
         $NameExtension = strtolower(pathinfo($Name, PATHINFO_EXTENSION));
         $FileExtension = strtolower(pathinfo($File, PATHINFO_EXTENSION));
         if ($NameExtension == '') {
            if ($Name == '') {
               $Name = pathinfo($File, PATHINFO_FILENAME) . '.' . $FileExtension;
            } elseif (!StringEndsWith($Name, '.'.$FileExtension)) {
             $Name .= '.'.$FileExtension;
            }
         } else {
            $Extension = $NameExtension;
         }
         $Name = rawurldecode($Name);
 
         // Figure out the MIME type
         $MimeTypes = array(
           "pdf"  => "application/pdf",
           "txt"  => "text/plain",
           "html" => "text/html",
           "htm"  => "text/html",
           "exe"  => "application/octet-stream",
           "zip"  => "application/zip",
           "doc"  => "application/msword",
           "xls"  => "application/vnd.ms-excel",
           "ppt"  => "application/vnd.ms-powerpoint",
           "gif"  => "image/gif",
           "png"  => "image/png",
           "jpeg" => "image/jpg",
           "jpg"  => "image/jpg",
           "php"  => "text/plain",
           "ico"  => "image/vnd.microsoft.icon"
         );
         
         if ($MimeType == '') {
            if (array_key_exists($FileExtension, $MimeTypes)){
              $MimeType = $MimeTypes[$FileExtension];
            } else {
              $MimeType = 'application/force-download';
            };
         };
         
         @ob_end_clean();
         
         // required for IE, otherwise Content-Disposition may be ignored
         if (ini_get('zlib.output_compression'))
            ini_set('zlib.output_compression', 'Off');
         
         if ($ServeMode == 'inline')
            header('Content-Disposition: inline; filename="'.$Name.'"');
         else
            header('Content-Disposition: attachment; filename="'.$Name.'"');
         
         header('Content-Type: '.$MimeType);
         header("Content-Transfer-Encoding: binary");
         header('Accept-Ranges: bytes');
         header("Cache-control: private");
         header('Pragma: private');
         header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
         readfile($File);
         exit();
      } else {
         die('not readable');
      }
   }