本文整理汇总了C#中IStorageFile.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# IStorageFile.GetStream方法的具体用法?C# IStorageFile.GetStream怎么用?C# IStorageFile.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStorageFile
的用法示例。
在下文中一共展示了IStorageFile.GetStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo
public bool CopyTo(IStorageFile target) {
var srcStream = this.GetStream();
if (srcStream == null) return false;
using (srcStream) {
using (var targetStream = target.GetStream(true))
{
const int bufferSize = 1024 * 2;
byte[] buffer = new byte[bufferSize];
int readCount = 0;
while ((readCount = srcStream.Read(buffer, 0, bufferSize)) > 0) {
targetStream.Write(buffer, 0, readCount);
}
}
}
return true;
}
示例2: CopyToAsync
public async Task<bool> CopyToAsync(IStorageFile target)
{
var srcStream = this.GetStream();
if (srcStream == null) return false;
using (srcStream)
{
using (var targetStream = target.GetStream(true))
{
const int bufferSize = 1024 * 2;
byte[] buffer = new byte[bufferSize];
int readCount = 0;
while ((readCount =await srcStream.ReadAsync(buffer, 0, bufferSize)) > 0)
{
await targetStream.WriteAsync(buffer, 0, readCount);
}
}
}
return true;
}
示例3: ServeOriginal
private IResult ServeOriginal( string path, IStorageFile storageFile, IFormatInfo outputFormat )
{
var stream = storageFile.GetStream();
IAddToCacheResult cacheResult;
if ( MediaCache.TryAddToCache( path, stream, outputFormat, out cacheResult ) )
{
return new CopyToOutputStreamResult( cacheResult.LastModified, cacheResult.ETag, storageFile.ContentLength, stream );
}
return storageFile;
}