I have a little problem:
I tried to read the text from a drag/dropped file, but I don't get access to the file. I don't really know what I did wrong. Is there a way to get the access to the file?
My code:
if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
var items = await e.DataView.GetStorageItemsAsync();
if (items.Count > 0)
{
foreach (var appFile in items.OfType<StorageFile>())
{
string text = await Windows.Storage.FileIO.ReadTextAsync(appFile);
}
}
}
This one should to work.
if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
foreach (IStorageItem TargetStorageItem in await DroppedDataInfo.GetStorageItemsAsync())
{
if(TargetStorageItem is StorageFile)
{
string text = await Windows.Storage.FileIO.ReadTextAsync(TargetStorageItem as StorageFile);
//Read only this first one in this case...
break;
}
}
}