Esempio n. 1
0
 private void Encode(string[] args)
 {
     if (args.Length < 2)
     {
         Console.WriteLine("You need to supply a valid filename.");
     }
     else
     {
         GetPassword(args);
         FileImageManager.Encode(args[1], password);
     }
 }
        public static void Retrieve(string source, bool encrypt)
        {
            string password = string.Empty;

            if (true == encrypt)
            {
                password = FileImageManager.GetPassword();
            }

            string newFilename = FileImageManager.GetFileNameHash(source);

            //flickr
            FileImageManager.Decode(newFilename + ".png", password);
        }
        public void Store(string source, bool isDirectory, bool recurse,
                          bool encrypt)
        {
            try
            {
                if ((true == encrypt) && (string.IsNullOrEmpty(password)))
                {
                    password = FileImageManager.GetPassword();
                }

                if (true == isDirectory)
                {
                    Directory.SetCurrentDirectory(source);

                    foreach (string file in Directory.GetFiles(source))
                    {
                        Store(file, false, false, true);
                    }

                    if (true == recurse)
                    {
                        foreach (string directory in
                                 Directory.GetDirectories(source))
                        {
                            Store(directory, true, true, true);
                        }
                    }
                }
                else
                {
                    FileImageManager.Encode(source, password);

                    string newFilename =
                        FileImageManager.GetFileNameHash(source);
                    flickr.UploadPicture(newFilename + ".png",
                                         newFilename + ".png", string.Empty, string.Empty,
                                         false, false, false);
                    File.Delete(newFilename + ".png");
                    Console.WriteLine("Uploaded " + source + " as " +
                                      newFilename + ".png");
                }
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }
        }