Beispiel #1
0
        private void ReplaceImage(string file, Guid streamId)
        {
            if (file.Count() > 0)
            {
                if (items == null)
                {
                    items = new List <ImageInfo>();
                }

                using (StorageStream s = storage.OpenStream(streamId))
                {
                    using (FileStream fs = File.OpenRead(file))
                    {
                        byte[] buf = new byte[65536];

                        int l = fs.Read(buf, 0, buf.Length);
                        while (l > 0)
                        {
                            s.Write(buf, 0, l);
                            l = fs.Read(buf, 0, buf.Length);
                        }
                    }

                    ImageInfo ii = items
                                   .Where(i => i.StreamId == streamId)
                                   .First();

                    ii.Name = System.IO.Path.GetFileName(file);
                    ii.Size = (int)s.Length;

                    s.SetLength(s.Position);
                }

                SaveImageList();
                UpdateUI();
                RefreshMap(imageList.SelectedValue as Guid?);
            }
        }