Skip to content

Instantly share code, notes, and snippets.

using (ZipArchive archive = new ZipArchive(model.File.InputStream, ZipArchiveMode.Read))
{
//archive.ExtractToDirectory(Statics.TemplatesPath);
foreach (ZipArchiveEntry entry in archive.Entries)
{
string fullPath = Path.Combine(Statics.TemplatesPath, entry.FullName);
if (string.IsNullOrEmpty(entry.Name))
{
@belchev
belchev / gist:24d6c06bdbaea6799383
Created November 11, 2015 10:55
Save memoryStream to local, when memorystream is already once read.
using (var fileStream = new FileStream(@"C:\Temp\test.zip", FileMode.Create))
{
memoryStream.Seek(0, SeekOrigin.Begin);
memoryStream.CopyTo(fileStream);
}
public class FileResult : IHttpActionResult
{
private readonly byte[] _fileBinary;
private readonly string _contentType;
private string _fileName;
public FileResult(byte[] fileBinary, string contentType, string fileName)
{
this._fileBinary = fileBinary;
this._contentType = contentType;
@belchev
belchev / gist:04580878904cadd984f7
Last active January 13, 2016 15:09
WCF send custom header request - dirty way
string url = "http://url.com/*.wsdl";
using (var client = new WebClient())
{
var data = System.IO.File.ReadAllText(HostingEnvironment.MapPath(@"~/App_Data/request.xml"));
client.Headers.Add("Content-Type", "text/xml;charset=utf-8");
client.Encoding = Encoding.GetEncoding("ISO-8859-1");
client.Credentials = new NetworkCredential("username", "pass");
client.Headers.Add("SOAPAction", "\"http://url.com/wsdl?action\"");