CameraCaptureTask を使用して画像をキャプチャし、IsolatedStorage に保存しています。recent
次に、これらの保存された画像を MainPage で指定したリストボックスに入力します。次に、ShareMediaTask を使用してこれらの画像の 1 つを共有したいと思います。ただし、私が問題を抱えている ShareMediaTask の要件は、IsolatedStorage からイメージのファイル パスを取得することです。私がやっていることは、リストボックスの SelectionChanged イベント ハンドラーを使用して、ユーザーが共有するために選択した画像を判断することです。次に、ボタン クリック イベントで、IsolatedStorage を検索して、リスト ボックスから選択した画像のフル パスを取得します。フル パスが表示されていても、ShareMediaTask は完了しません。
MainPage.xaml.cs
//The `recent` ListBox's SelectionChanged event
private void recent_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//retrieve the name of the image that was autogenerated by CameraCaptureTask completed event
fileName = capturedPicture.FileName;
//Combine the directory and file name
filePath = Path.Combine(PictureRepository.IsolatedStoragePath, fileName);
}
private void Share()
{
if(fileName != null)
{
var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
//use the path to open the picture file from the isolated storage by using the IsolatedStorageFile.OpenFile method
var fileStream = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read);
string name = fileStream.Name;
_shareTask = new ShareMediaTask();
_shareTask.FilePath = name;
_shareTask.Show();
}
}
ボタン クリック イベントを介して呼び出されるShare()
メソッドでは、IsolatedStorage 内の画像のフル パスを取得する唯一の方法は、IsolatedStorageFile.OpenFile
アクセスできるメソッドを使用することですfileStream.Name
。まだうまくいかないようです。