本文整理汇总了C#中System.IO.Abstractions.FileInfoBase.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfoBase.Delete方法的具体用法?C# FileInfoBase.Delete怎么用?C# FileInfoBase.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Abstractions.FileInfoBase
的用法示例。
在下文中一共展示了FileInfoBase.Delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SmartDeleteFile
private void SmartDeleteFile(FileInfoBase fileToDelete)
{
TryFileFuncAndMoveFileOnFailure(() =>
{
fileToDelete.Delete();
return null;
}, fileToDelete.FullName);
}
示例2: CreateFileDeleteResponse
protected virtual Task<HttpResponseMessage> CreateFileDeleteResponse(FileInfoBase info)
{
// Generate file response
try
{
using (Stream fileStream = GetFileDeleteStream(info))
{
info.Delete();
}
HttpResponseMessage successResponse = Request.CreateResponse(HttpStatusCode.OK);
return Task.FromResult(successResponse);
}
catch (Exception e)
{
// Could not delete the file
Tracer.TraceError(e);
HttpResponseMessage notFoundResponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, e);
return Task.FromResult(notFoundResponse);
}
}
示例3: Remux
//.........这里部分代码省略.........
var name2 = name + ".stage2" + outputFile.Extension;
var workingAreaStage1File = fileSystem.FileInfo.FromFileName(fileSystem.Path.Combine(workingArea.FullName, name1));
var workingAreaStage2File = fileSystem.FileInfo.FromFileName(fileSystem.Path.Combine(workingArea.FullName, name2));
// Working variables.
var maps = new StringBuilder();
var codecs = new StringBuilder();
var outputStreamIndex = 0;
// Copy video streams.
var h264 = videoStreams.Where(stream => stream.Codec == MediaStreamsExtractor.CodecType.H264).ToList();
if(h264.Any())
{
h264.Where(stream => stream.Codec == MediaStreamsExtractor.CodecType.H264).ToList().ForEach(stream => MakeCopyStream(stream, maps, codecs, outputStreamIndex++));
}
else
{
LogError("Unable to find h264 stream. Will not remux.");
return;
}
// Copy or transcode aac 2 channel audio streams.
var acc2Channel = audioStreams.Where(stream => stream.Codec == MediaStreamsExtractor.CodecType.AAC && stream.Channels == 2).ToList();
if(acc2Channel.Any())
{
acc2Channel.ForEach(stream => MakeCopyStream(stream, maps, codecs, outputStreamIndex++));
}
else
{
// Transcode aac 2 channel audio stream from all available audio streams.
audioStreams.ForEach(stream =>
{
maps.AppendFormat(" -map 0:{0} ", stream.Id);
codecs.AppendFormat(" -c:{0} aac -ac:a 2 ", outputStreamIndex++);
});
}
// Copy or transcode higher quality audio stream if possible.
var ac36Channel = audioStreams.Where(stream => stream.Codec == MediaStreamsExtractor.CodecType.AC3 && stream.Channels == 6).ToList();
var dts = audioStreams.Where(stream => stream.Codec == MediaStreamsExtractor.CodecType.DTS).ToList();
// Copy ac3 6 channel streams if exists.
if(ac36Channel.Any())
{
ac36Channel.ForEach(stream => MakeCopyStream(stream, maps, codecs, outputStreamIndex++));
}
else if(dts.Any())
{
// Transcode ac3 6 channel audio streams from dts streams.
dts.ForEach(stream =>
{
maps.AppendFormat(" -map 0:{0} ", stream.Id);
codecs.AppendFormat(" -c:{0} ac3 -ac:a 6 ", outputStreamIndex++);
});
}
// Copy dts streams if exists.
dts.ForEach(stream => MakeCopyStream(stream, maps, codecs, outputStreamIndex++));
// Transcode in subtitles if exists.
subtitleStreams.ForEach(stream =>
{
maps.AppendFormat(" -map 0:{0} ", stream.Id);
codecs.AppendFormat(" -c:{0} mov_text ", outputStreamIndex++);
});
// Mov atom detils.
var movFlags = "";
if(string.Compare(outputFile.Extension, ".m4v", System.StringComparison.OrdinalIgnoreCase)==0
|| string.Compare(outputFile.Extension, ".mp4", System.StringComparison.OrdinalIgnoreCase)==0)
{
movFlags = " -movflags faststart ";
}
// Remux.
var remuxArguments = string.Format("-i \"{0}\" -y -strict experimental {1} {2} {3} \"{4}\"", inputFile.FullName, maps, codecs, movFlags, workingAreaStage1File.FullName);
LogOutput("Running FFmpeg with arguments {0}", remuxArguments);
External.Run(External.Application.FFmpeg, remuxArguments, StdOut, StdErr);
// Optimise tracks.
var sublerArguments = string.Format ("-source \"{0}\" -dest \"{1}\" -optimize -itunesfriendly", workingAreaStage1File.FullName, workingAreaStage2File.FullName);
LogOutput("Running Subler to optimize track with arguments {0}", sublerArguments);
External.Run(External.Application.SublerCLI, sublerArguments, StdOut, StdErr);
// Delete stage1 file.
LogOutput("Deleting workingAreaFile1 {0}", workingAreaStage1File.FullName);
workingAreaStage1File.Delete();
// Delete output file if it already exists.
if(outputFile.Exists)
{
LogOutput("Output file {0} already exists. Will delete.", outputFile.FullName);
outputFile.Delete();
}
// Move stage 2 file to output file location.
LogOutput("Moving newly created remux file {0} to output file location {1}.", workingAreaStage2File.FullName, outputFile.FullName);
workingAreaStage2File.MoveTo(outputFile.FullName);
};
}