本文整理汇总了C#中Package.ExtractToDirectoryAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Package.ExtractToDirectoryAsync方法的具体用法?C# Package.ExtractToDirectoryAsync怎么用?C# Package.ExtractToDirectoryAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package.ExtractToDirectoryAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeployAsync
public async Task DeployAsync(IApp app, Package package)
{
#region Ensure the app exists
var instance = Find(app.Id);
if (instance == null)
{
await CreateAsync(app).ConfigureAwait(false);
}
#endregion
var directory = GetAppPath(app);
if (directory.Exists) throw new Exception($"Directory '{directory.FullName}' already exists");
try
{
await package.ExtractToDirectoryAsync(directory).ConfigureAwait(false);
}
catch
{
directory.Delete(true);
throw;
}
// TODO, download the keychain
#region Set Access Control
var accountName = "IIS AppPool\\" + app.Name;
log.Info($"Setting ACL for {accountName}");
var rights = FileSystemRights.ReadData | FileSystemRights.ReadAndExecute;
// Current settings
var accessControl = directory.GetAccessControl();
// Add the FileSystemAccessRule to the security settings.
accessControl.AddAccessRule(new FileSystemAccessRule(
accountName,
rights,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow
));
try
{
directory.SetAccessControl(accessControl);
}
catch (Exception ex)
{
log.Error($"Error creating ACL. {ex.Message}");
}
#endregion
// Ensure the rights have propogated
await Task.Delay(TimeSpan.FromMilliseconds(30)).ConfigureAwait(false);
LogInfo(app, $"Deployed v{app.Version}");
}