Exemplo n.º 1
0
        private ZipArchive ExtractImages(CreativeSet c, ZipArchive zipArchive)
        {
            Type type = c.GetType();
            // get all public static properties of MyClass type
            var propertyInfos = type.GetProperties();

            foreach (var p in propertyInfos)
            {
                if (p.Name.Contains("Image"))
                {
                    //Create a zip entry for each attachment
                    var    zipEntry = zipArchive.CreateEntry(c.SetName + p.Name);
                    string name     = p.Name;
                    if (c.GetType().GetProperty(p.Name).GetValue(c) != null)
                    {
                        var url = c.GetType().GetProperty(p.Name).GetValue(c).ToString();

                        var    webClient  = new WebClient();
                        byte[] imageBytes = webClient.DownloadData(url);
                        //Get the stream of the attachment
                        using (var originalFileStream = new MemoryStream(imageBytes))
                            using (var zipEntryStream = zipEntry.Open())
                            {
                                //Copy the attachment stream to the zip entry stream
                                originalFileStream.CopyTo(zipEntryStream);
                            }
                    }
                }
            }
            return(zipArchive);
        }
Exemplo n.º 2
0
        public ActionResult Edit(CreativeSet set)
        {
            Type thisOne = set.GetType();

            return(View());
        }