private void CommitItems(List <UpdateItem> updateItems, string rootDirectory, string sourceDirectory) { string relativeDirectory = sourceDirectory.Substring(rootDirectory.Length).TrimStart(new char [] { '\\' }); foreach (string directory in Directory.GetDirectories(sourceDirectory)) { CommitItems(updateItems, rootDirectory, directory); } foreach (string filename in Directory.GetFiles(sourceDirectory)) { bool foundExistingItem = false; foreach (UpdateItem updateItem in updateItems) { if (updateItem.RelativeDirectory == relativeDirectory && updateItem.Name == Path.GetFileName(filename)) { AutoUpdateManager.DeleteFileFromPackage(this.Target, updateItem.RelativeDirectory, updateItem.Name); AutoUpdateManager.AddFileToPackage(this.Target, relativeDirectory, filename); if (updateItem.IsProtected == true) { AutoUpdateManager.SetFileProtectionForPackage(this.Target, relativeDirectory, Path.GetFileName(filename), updateItem.IsProtected); } if (updateItem.IsIncluded == false) { AutoUpdateManager.SetFileInclusionForPackage(this.Target, relativeDirectory, Path.GetFileName(filename), updateItem.IsIncluded); } foundExistingItem = true; break; } } if (foundExistingItem == false) { AutoUpdateManager.AddFileToPackage(this.Target, relativeDirectory, filename); } } // Clean up files that are no longer in the package. foreach (UpdateItem updateItem in updateItems) { if (updateItem.RelativeDirectory == relativeDirectory) { if (File.Exists(Path.Combine(sourceDirectory, updateItem.Name)) == false) { AutoUpdateManager.DeleteFileFromPackage(this.Target, updateItem.RelativeDirectory, updateItem.Name); } } } }
protected void txtFileToDelete_ValueChanged(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtFileToDelete.Value) == true) { return; } AutoUpdateManager.DeleteFileFromPackage(Target, txtFileToDeleteRelativeDirectory.Value, txtFileToDelete.Value); txtFileToDelete.Value = ""; BindData(); }
protected void wcFileManager_SelectedItemsAction(object sender, IZ.WebFileManager.SelectedItemsActionCancelEventArgs e) { //string relativePath = e.DestinationDirectory.FileManagerPath.Replace('/', '\\').TrimStart(new char[] { '\\' }); string destinationRelativePath = TrimPackageNameFromVirtualPathAndMakeRelative(this.Target, e.DestinationDirectory.FileManagerPath); switch (e.Action) { case IZ.WebFileManager.SelectedItemsAction.Copy: foreach (var selectedItem in e.SelectedItems) { string sourceFile = TrimPackageNameFromVirtualPathAndMakeRelative(this.Target, selectedItem.FileManagerPath); AutoUpdateManager.CopyFileInPackage(this.Target, Path.GetDirectoryName(sourceFile), Path.GetFileName(sourceFile), destinationRelativePath); } break; case IZ.WebFileManager.SelectedItemsAction.Delete: foreach (var selectedItem in e.SelectedItems) { if ((File.GetAttributes(selectedItem.PhysicalPath) & FileAttributes.Directory) == FileAttributes.Directory) { AutoUpdateManager.DeleteFolderFromPackage(this.Target, destinationRelativePath); } else { AutoUpdateManager.DeleteFileFromPackage(this.Target, destinationRelativePath, Path.GetFileName(selectedItem.PhysicalPath)); } } break; case IZ.WebFileManager.SelectedItemsAction.Move: foreach (var selectedItem in e.SelectedItems) { if ((File.GetAttributes(selectedItem.PhysicalPath) & FileAttributes.Directory) == FileAttributes.Directory) { AutoUpdateManager.MoveFolderInPackage(this.Target, TrimPackageNameFromVirtualPathAndMakeRelative(this.Target, selectedItem.FileManagerPath), destinationRelativePath); } else { AutoUpdateManager.MoveFileInPackage(this.Target, TrimPackageNameFromVirtualPathAndMakeRelative(this.Target, selectedItem.FileManagerPath), Path.GetFileName(selectedItem.PhysicalPath), destinationRelativePath, Path.GetFileName(selectedItem.PhysicalPath)); } } break; } }