/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewTemporaryFileCommand.cs
49 строк
2 KB
xtqqczze
Fix IDE0090: Simplify new expression part 4.5 (#14259)
27 ноя 2020, 06:17
Не верифицирован
27 ноя 2020, 06:17
edb70b1
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.IO; using System.Management.Automation; namespace Microsoft.PowerShell.Commands { /// <summary> /// The implementation of the "New-TemporaryFile" cmdlet. /// </summary> [Cmdlet(VerbsCommon.New, "TemporaryFile", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Low, HelpUri = "https://go.microsoft.com/fwlink/?LinkId=2097032")] [OutputType(typeof(System.IO.FileInfo))] public class NewTemporaryFileCommand : Cmdlet { /// <summary> /// Returns a TemporaryFile. /// </summary> protected override void EndProcessing() { string filePath = null; string tempPath = Path.GetTempPath(); if (ShouldProcess(tempPath)) { try { filePath = Path.GetTempFileName(); } catch (IOException ioException) { ThrowTerminatingError( new ErrorRecord( ioException, "NewTemporaryFileWriteError", ErrorCategory.WriteError, tempPath)); return; } if (!string.IsNullOrEmpty(filePath)) { FileInfo file = new(filePath); WriteObject(file); } } } } }