@@ -1055,7 +1055,7 @@ public async Task PasteItems(DataPackageView packageView, string destinationPath
1055
1055
StatusBanner . StatusBannerOperation . Paste ) ;
1056
1056
}
1057
1057
1058
- await Task . Run ( ( Func < Task > ) ( async ( ) =>
1058
+ await Task . Run ( async ( ) =>
1059
1059
{
1060
1060
foreach ( IStorageItem item in itemsToPaste )
1061
1061
{
@@ -1147,15 +1147,24 @@ await ItemViewModel.GetFolderFromPathAsync(destinationPath),
1147
1147
{
1148
1148
try
1149
1149
{
1150
+ if ( string . IsNullOrEmpty ( item . Path ) )
1151
+ {
1152
+ // Can't move (only copy) files from MTP devices because:
1153
+ // StorageItems returned in DataPackageView are read-only
1154
+ // The item.Path property will be empty and there's no way of retrieving a new StorageItem with R/W access
1155
+ continue ;
1156
+ }
1150
1157
if ( item . IsOfType ( StorageItemTypes . File ) )
1151
1158
{
1152
- StorageFile file = ( StorageFile ) item ;
1153
- await file . DeleteAsync ( ) ;
1159
+ // If we reached this we are not in an MTP device, using StorageFile.* is ok here
1160
+ StorageFile file = await StorageFile . GetFileFromPathAsync ( item . Path ) ;
1161
+ await file . DeleteAsync ( StorageDeleteOption . PermanentDelete ) ;
1154
1162
}
1155
1163
else if ( item . IsOfType ( StorageItemTypes . Folder ) )
1156
1164
{
1157
- StorageFolder folder = ( StorageFolder ) item ;
1158
- await folder . DeleteAsync ( ) ;
1165
+ // If we reached this we are not in an MTP device, using StorageFolder.* is ok here
1166
+ StorageFolder folder = await StorageFolder . GetFolderFromPathAsync ( item . Path ) ;
1167
+ await folder . DeleteAsync ( StorageDeleteOption . PermanentDelete ) ;
1159
1168
}
1160
1169
}
1161
1170
catch ( FileNotFoundException )
@@ -1166,7 +1175,7 @@ await ItemViewModel.GetFolderFromPathAsync(destinationPath),
1166
1175
ListedItem listedItem = CurrentInstance . FilesystemViewModel . FilesAndFolders . FirstOrDefault ( listedItem => listedItem . ItemPath . Equals ( item . Path , StringComparison . OrdinalIgnoreCase ) ) ;
1167
1176
}
1168
1177
}
1169
- } ) ) ;
1178
+ } ) ;
1170
1179
1171
1180
if ( destinationPath == CurrentInstance . FilesystemViewModel . WorkingDirectory )
1172
1181
{
0 commit comments