本文整理汇总了C#中FileEntry.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# FileEntry.ThrowIfNull方法的具体用法?C# FileEntry.ThrowIfNull怎么用?C# FileEntry.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileEntry
的用法示例。
在下文中一共展示了FileEntry.ThrowIfNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
/// <summary>
/// Deletes the specified path.
/// </summary>
/// <param name="fileEntry">The file entry.</param>
/// <exception cref="System.IO.IOException">If the command fails.</exception>
public void Delete( FileEntry fileEntry )
{
/// <exception cref="System.ArgumentNullException">
/// If device is null
/// or
/// If path is null or empty.
/// </exception>
Device.ThrowIfNull("Device");
fileEntry.ThrowIfNull ( "fileEntry" );
if ( fileEntry.Exists ) {
CommandErrorReceiver cer = new CommandErrorReceiver ( );
Device.ExecuteShellCommand ( "rm -f {0} {1}", cer, fileEntry.IsDirectory ? "-r" : String.Empty, fileEntry.FullResolvedPath );
if ( !String.IsNullOrEmpty ( cer.ErrorMessage ) ) {
throw new IOException ( cer.ErrorMessage );
}
}
}
示例2: Delete
/// <summary>
/// Deletes the specified path.
/// </summary>
/// <param name="path">The path.</param>
public void Delete( FileEntry fileEntry )
{
Device.ThrowIfNull ( "Device" );
fileEntry.ThrowIfNull ( "fileEntry" );
if ( fileEntry.Exists ) {
CommandErrorReceiver cer = new CommandErrorReceiver ( );
Device.ExecuteShellCommand ( "rm -f {0} {1}", cer, fileEntry.IsDirectory ? "-r" : String.Empty, fileEntry.FullResolvedPath );
if ( !String.IsNullOrEmpty ( cer.ErrorMessage ) ) {
throw new IOException ( cer.ErrorMessage );
}
}
}