Пример #1
0
        public void uploadImage(ImageMessage imageMessage)
        {
            String imageName   = imageMessage.name;
            Stream imageStream = imageMessage.image;

            saveFile(imageStream, System.Environment.CurrentDirectory + "\\images\\" + imageName);
        }
Пример #2
0
        public ImageMessage downloadImage(ImageNameMessage imageName)
        {
            ImageMessage result = new ImageMessage();

            result.name = imageName.name;
            string     imagePath = Path.Combine(System.Environment.CurrentDirectory, ".\\images\\" + imageName.name);
            FileStream image;

            try
            {
                image = File.OpenRead(imagePath);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                throw e;
            }
            result.image = image;
            result.size  = image.Length;
            return(result);
        }