我在从媒体库中获取图像时遇到了一些问题,我想知道是否有任何选项可以仅获取或自动过滤媒体库中的特定图像。例如,假设我有像1.jpg,2.jpg,3.jpg........etc这样的图像。我从媒体库中获取图像,并将所有图像保存在独立存储中,因此我只想从媒体库中获取特定图像,而不是所有图像,以下是我的代码
using (MediaLibrary mediaLibrary = new MediaLibrary())
{
PictureCollection AllScreenShot = mediaLibrary.Pictures;
foreach (Picture picture in AllScreenShot)
{
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!storage.DirectoryExists("SavedImg"))
storage.CreateDirectory("SavedImg");
if (storage.FileExists("SavedImg" + "\\" + picture.Name))
storage.DeleteFile("SavedImg" + "\\" + picture.Name);
using (IsolatedStorageFileStream file = storage.CreateFile("SavedImg" + "\\" + picture.Name))
picture.GetImage().CopyTo(file);
}
}
}发布于 2014-07-15 14:19:00
这会有帮助的
var picture = media.Pictures.FirstOrLast(p => p.Name.Contains("1.jpg"));
if (picture == null)
{
// 1.jpg not found
}
else
{
//1.jpg found
}https://stackoverflow.com/questions/24750376
复制相似问题