コード例 #1
0
        public string CreateImageUri(string rootUri, DevExpress.Office.Utils.OfficeImage image, string relativeUri)
        {
            string imagesDir = String.Format("{0}\\{1}", this.rootDirecory, rootUri.Trim('/'));

            if (!Directory.Exists(imagesDir))
            {
                Directory.CreateDirectory(imagesDir);
            }
            string imageName = String.Format("{0}\\{1}.png", imagesDir, Guid.NewGuid());

            image.NativeImage.Save(imageName, ImageFormat.Png);
            return(GetRelativePath(imageName));
        }
        public string CreateImageUri(string rootUri, DevExpress.Office.Utils.OfficeImage image, string relativeUri)
        {
            string imagesDir = String.Format("{0}\\{1}", this.rootDirecory, rootUri.Trim('/'));

            if (!store.DirectoryExists(imagesDir))
            {
                store.CreateDirectory(imagesDir);
            }
            string imageName = String.Format("{0}\\{1}.png", imagesDir, Guid.NewGuid());

            using (IsolatedStorageFileStream fStream = store.CreateFile(imageName)) {
                using (MemoryStream ms = new MemoryStream(image.GetImageBytesSafe(OfficeImageFormat.Png)))
                    ms.WriteTo(fStream);
            }
            return(GetRelativePath(imageName));
        }
        public string CreateImageUri(string rootUri, DevExpress.Office.Utils.OfficeImage image, string relativeUri)
        {
            string imagesDir = String.Format("{0}\\{1}", this.rootDirectory, rootUri.Trim('/'));

            if (!Directory.Exists(imagesDir))
            {
                Directory.CreateDirectory(imagesDir);
            }
            string imageName = String.Format("{0}\\{1}.png", imagesDir, Guid.NewGuid());

            byte[] bytes = image.GetImageBytesSafe(OfficeImageFormat.Png);
            using (FileStream stream = new FileStream(imageName, FileMode.Create, FileAccess.Write))
            {
                stream.Write(bytes, 0, bytes.Length);
                stream.Close();
            }
            return(GetRelativePath(imageName));
        }