public static GetMIMEType ( string extension ) : string | ||
extension | string | |
Результат | string |
private bool ServeEmbeddedResource(HTTPResponse response, Assembly assembly, string strippedResourceName) { string fullResourceName = FullResourceName(assembly, strippedResourceName); if (!string.IsNullOrEmpty(fullResourceName)) { try { using (Stream resourceStream = assembly.GetManifestResourceStream(fullResourceName)) if (resourceStream != null) { string extension = Path.GetExtension(strippedResourceName); response.SetHeader(HTTPHeader.ContentType, MIMETypeMap.GetMIMEType(extension)); response.SetHeader(HTTPHeader.LastModified, File.GetLastWriteTime(assembly.Location).ToHTTPDate()); response.WriteStream(resourceStream); return(true); } } catch { } } return(false); }
private void ServeFile(string filePath, HTTPResponse response) { string extension = Path.GetExtension(filePath); response.SetHeader(HTTPHeader.ContentType, MIMETypeMap.GetMIMEType(extension)); response.SetHeader(HTTPHeader.LastModified, System.IO.File.GetLastWriteTime(filePath).ToHTTPDate()); using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) response.WriteStream(stream); }
private void ServeFile(string filePath, HTTPResponse response) { string extension = Path.GetExtension(filePath); response.SetHeader(HTTPHeader.ContentType, MIMETypeMap.GetMIMEType(extension)); response.SetHeader(HTTPHeader.LastModified, System.IO.File.GetLastWriteTime(filePath).ToHTTPDate()); FileStream file = File.Open(filePath, FileMode.Open); response.WriteStream(file); file.Close(); }