Example #1
0
 private void fileSystemWatcher_Renamed(object sender, RenamedEventArgs e)
 {
     string S3Key = Utils.GetKeyByPath(e.FullPath, strLocalPath);
     string FileType = "File";
     if (Directory.Exists(e.FullPath))
     {
         S3Key += "/";
         FileType = "Directory";
     }
     try
     {
         if (FileType != "Directory")
         {
             S3Object S3Obj = new S3Object(S3Conn, BucketName, Utils.GetKeyByPath(e.OldFullPath, strLocalPath));
             S3Obj.Delete();
             S3Obj = new S3Object(S3Conn, BucketName, S3Key);
             S3Obj.Upload(e.FullPath);
         }
         else
         {
             Bucket.DeleteDirectory(S3Key);
             Utils.ListDirectory(e.FullPath);
             foreach (var StrPath in Utils.AlDirectories)
             {
                 string S3KeyOfDir = Utils.GetKeyByPath((string)StrPath, strLocalPath);
                 S3KeyOfDir += "/";
                 S3Object S3Obj = new S3Object(S3Conn, BucketName, S3KeyOfDir);
                 S3Obj.Upload(StrPath.ToString());
                 showNotifyMessage("Upload Directory", (string)StrPath);
             }
             foreach (var StrPath in Utils.AlFiles)
             {
                 string S3KeyOfDir = Utils.GetKeyByPath((string)StrPath, strLocalPath);
                 S3Object S3Obj = new S3Object(S3Conn, BucketName, S3KeyOfDir);
                 S3Obj.Upload(StrPath.ToString());
                 showNotifyMessage("Upload File", (string)StrPath);
             }
         }
         this.showNotifyMessage(FileType + " Renamed", S3Key);
     }
     catch (Exception ee)
     {
         showErrorMessage("Error", ee.Message);
     }
 }
Example #2
0
 public void DeleteDirectory(string DirectoryName)
 {
     foreach (var S3Obj in this.Keys)
     {
         if (S3Obj.Key.ToLower().StartsWith(DirectoryName.ToLower()))
         {
             S3Object S3O = new S3Object(Connection, m_name, S3Obj.Key);
             S3O.Delete();
         }
     }
 }  
Example #3
0
 private void fileSystemWatcher_Deleted(object sender, FileSystemEventArgs e)
 {
     string S3Key = Utils.GetKeyByPath(e.FullPath, strLocalPath);
     try
     {
         S3Object S3Obj = new S3Object(S3Conn, BucketName, S3Key);
         S3Obj.Delete();
         Bucket.DeleteDirectory(S3Key + "/");
         this.showNotifyMessage("File or Directory Deleted", e.FullPath);
     }
     catch (Exception ee)
     {
         showErrorMessage("Error", ee.Message);
     }
 }