どうぞ :)
保存するフォルダを使用できないことに注意してください。目的地として通過ApplicationData.Current.LocalFolder.Path
しました。FolderPicker
選択したフォルダーのパスを使用して渡すことができます。
private async Task StoreImageFromClipboardAsync()
{
var dataPackage = Clipboard.GetContent();
var formats = dataPackage.AvailableFormats;
if (formats.Contains("Bitmap"))
{
var t = await dataPackage.GetBitmapAsync();
var file = await ChangeIRASRToStorageFileAsync(t, ApplicationData.Current.LocalFolder.Path, "Clipboard.png");
}
}
private async Task<StorageFile> ChangeIRASRToStorageFileAsync(IRandomAccessStreamReference MyIRASR, String StorageFolderPath, String StorageFileName)
{
IRandomAccessStreamWithContentType MyIRASWCT = await MyIRASR.OpenReadAsync();
StorageFolder MyStorageFolder = await StorageFolder.GetFolderFromPathAsync(StorageFolderPath);
StorageFile MyStorageFile = await MyStorageFolder.CreateFileAsync(StorageFileName, CreationCollisionOption.ReplaceExisting);
Windows.Storage.Streams.Buffer MyBuffer = new Windows.Storage.Streams.Buffer(Convert.ToUInt32(MyIRASWCT.Size));
IBuffer iBuf = await MyIRASWCT.ReadAsync(MyBuffer, MyBuffer.Capacity, InputStreamOptions.None);
await FileIO.WriteBufferAsync(MyStorageFile, iBuf);
return MyStorageFile;
}