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); } } } }
public void SetFileProtectionForPackage(string packageName, string relativeDirectory, string fileName, bool isProtected) { CheckAccess(); AutoUpdateManager.SetFileProtectionForPackage(packageName, relativeDirectory, fileName, isProtected); }