private void Deletefolder(string relativePath)
 {
     if (relativePath.ToLower().IndexOf("shared") != 0)
     {
         // Iteration through all the files in the folder
         try
         {
             foreach (
                 var s3Object in
                     _amazons3.ListObjects(new ListObjectsRequest { BucketName = Utilities.MyConfig.BucketKey, Prefix = relativePath })
                         .S3Objects)
             {
                 try
                 {
                     _amazons3.DeleteObject(new Amazon.S3.Model.DeleteObjectRequest { BucketName = Utilities.MyConfig.BucketKey, Key = s3Object.Key });
                     DeleteObjectVersions(s3Object.Key);
                 }
                 catch (Exception)
                 {
                     continue;
                 }
             }
             foreach (var resultEntry in _service.ListAllObjects(Utilities.MyConfig.BucketKey, relativePath))
             {
                 ObjectEntry entry;
                 try
                 {
                     entry = (ObjectEntry)resultEntry;
                     try
                     {
                         var removeobject = new DeleteObjectRequest(_service, Utilities.MyConfig.BucketKey,
                                                                    entry.Key);
                         removeobject.GetResponse();
                         DeleteObjectVersions(entry.Key);
                     }
                     catch (Exception)
                     {
                         try
                         {
                             var removeobject = new DeleteObjectRequest(_service, Utilities.MyConfig.BucketKey,
                                                                        entry.Name);
                             removeobject.GetResponse();
                             DeleteObjectVersions(entry.Name);
                         }
                         catch (Exception)
                         {
                             continue;
                         }
                     }
                 }
                 catch (Exception)
                 {
                     try
                     {
                         var prefix = (CommonPrefix)resultEntry;
                         Deletefolder(prefix.Prefix);
                     }
                     catch (Exception)
                     {
                         continue;
                     }
                 }
             }
         }
         catch (Exception)
         {
             // Todo
             // need to hanlde something when error raises
         }
         finally
         {
             // deleting entire folder
             ProcessApplicationUpdates(new AppUpdateInfo
                                           {
                                               Key = relativePath.Replace("\\", "/"),
                                               LastModifiedTime = DateTime.Now,
                                               Status = UpdateStatus.Delete
                                           }, false, string.Empty);
             //_applicationUpates.Enqueue(new AppUpdateInfo { Key = relativePath.Replace("\\", "/"), LastModifiedTime = DateTime.Now, Status = UpdateStatus.Delete });
         }
         // If the user deleted a folder, it will be an exception
         try
         {
             //var attribute = File.GetAttributes(Path.Combine(Utilities.Path, relativePath));
             var removeobject = new DeleteObjectRequest(_service, Utilities.MyConfig.BucketKey, relativePath);
             removeobject.GetResponse();
         }
         catch (Exception)
         {
             return;
         }
     }
 }
 private void Removefolder(string path)
 {
     try
     {
         // If the user deleted a folder, it will be an exception
         string oldrelativePath = path.Replace(Utilities.Path + "\\", "").Replace("\\", "/");
         var removeobject = new DeleteObjectRequest(_service, Utilities.MyConfig.BucketKey, oldrelativePath + "/");
         removeobject.GetResponse();
         //_applicationUpates.Enqueue(new AppUpdateInfo { Key = oldrelativePath.Replace("\\", "/"), LastModifiedTime = DateTime.Now, Status = UpdateStatus.Delete });
         if (oldrelativePath.ToLower().IndexOf("shared") == 0)
         {
         }
         else
             ProcessApplicationUpdates(new AppUpdateInfo { Key = oldrelativePath.Replace("\\", "/"), LastModifiedTime = DateTime.Now, Status = UpdateStatus.Delete }, false, string.Empty);
     }
     catch (Exception)
     {
         return;
     }
 }