本文整理汇总了C#中System.IO.FileStream.CopyStreamTo方法的典型用法代码示例。如果您正苦于以下问题:C# FileStream.CopyStreamTo方法的具体用法?C# FileStream.CopyStreamTo怎么用?C# FileStream.CopyStreamTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileStream
的用法示例。
在下文中一共展示了FileStream.CopyStreamTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImageEnumerator
public IEnumerable<Image> GetImageEnumerator()
{
if (!isWorking && File.Exists(CachePath) && indexList != null && indexList.Count > 0)
{
using (FileStream fsCache = new FileStream(CachePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
foreach (LocationInfo index in indexList)
{
using (MemoryStream ms = new MemoryStream())
{
fsCache.CopyStreamTo(ms, (int)index.Location, (int)index.Length);
yield return Image.FromStream(ms);
}
}
}
}
}
示例2: GetImageEnumerator
public IEnumerable<Image> GetImageEnumerator()
{
if (!IsWorking && File.Exists(Options.OutputPath) && indexList != null && indexList.Count > 0)
{
using (FileStream fsCache = new FileStream(Options.OutputPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
foreach (LocationInfo index in indexList)
{
if (index.Location > int.MaxValue || index.Length > int.MaxValue)
{
MessageBox.Show(string.Format("Cache file size cannot exceed {0} Bytes.\r\nPlease use FFmpeg screen recording instead of GIF.", int.MaxValue), "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
yield break;
}
using (MemoryStream ms = new MemoryStream())
{
fsCache.CopyStreamTo(ms, (int)index.Location, (int)index.Length);
yield return Image.FromStream(ms);
}
}
}
}
}
示例3: PrepareDataFromFile
private Stream PrepareDataFromFile(string fp)
{
Stream data = null;
using (var fs = new FileStream(fp, FileMode.Open, FileAccess.Read, FileShare.Read))
{
data = new MemoryStream();
fs.CopyStreamTo(data);
}
return data;
}