@@ -125,10 +125,7 @@ public override IAsyncAction DeleteAsync(StorageDeleteOption option)
125
125
126
126
public override IAsyncOperation < BaseBasicProperties > GetBasicPropertiesAsync ( )
127
127
{
128
- return AsyncInfo . Run ( async ( cancellationToken ) =>
129
- {
130
- return new BaseBasicProperties ( ) ;
131
- } ) ;
128
+ return Task . FromResult ( new BaseBasicProperties ( ) ) . AsAsyncOperation ( ) ;
132
129
}
133
130
134
131
public override IAsyncOperation < BaseStorageFolder > GetParentAsync ( )
@@ -145,16 +142,13 @@ public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Thumbnai
145
142
146
143
public static IAsyncOperation < BaseStorageFile > FromPathAsync ( string path )
147
144
{
148
- return AsyncInfo . Run < BaseStorageFile > ( async ( cancellationToken ) =>
145
+ if ( IsNativePath ( path ) && CheckAccess ( path ) )
149
146
{
150
- if ( IsNativePath ( path ) && CheckAccess ( path ) )
151
- {
152
- var name = IO . Path . GetFileName ( path ) ;
153
- return new NativeStorageFile ( path , name . Substring ( name . LastIndexOf ( ":" ) + 1 ) , DateTime . Now ) ;
154
- }
155
- return null ;
156
- } ) ;
157
- }
147
+ var name = IO . Path . GetFileName ( path ) ;
148
+ return Task . FromResult ( ( BaseStorageFile ) new NativeStorageFile ( path , name [ ( name . LastIndexOf ( ":" ) + 1 ) ..] , DateTime . Now ) ) . AsAsyncOperation ( ) ;
149
+ }
150
+ return Task . FromResult < BaseStorageFile > ( null ) . AsAsyncOperation ( ) ;
151
+ }
158
152
159
153
private static bool CheckAccess ( string path )
160
154
{
@@ -207,11 +201,8 @@ public override IAsyncAction MoveAsync(IStorageFolder destinationFolder, string
207
201
208
202
public override IAsyncOperation < IRandomAccessStream > OpenAsync ( FileAccessMode accessMode )
209
203
{
210
- return AsyncInfo . Run < IRandomAccessStream > ( async ( cancellationToken ) =>
211
- {
212
- var hFile = NativeFileOperationsHelper . OpenFileForRead ( Path , accessMode == FileAccessMode . ReadWrite ) ;
213
- return new FileStream ( hFile , accessMode == FileAccessMode . ReadWrite ? FileAccess . ReadWrite : FileAccess . Read ) . AsRandomAccessStream ( ) ;
214
- } ) ;
204
+ var hFile = NativeFileOperationsHelper . OpenFileForRead ( Path , accessMode == FileAccessMode . ReadWrite ) ;
205
+ return Task . FromResult ( new FileStream ( hFile , accessMode == FileAccessMode . ReadWrite ? FileAccess . ReadWrite : FileAccess . Read ) . AsRandomAccessStream ( ) ) . AsAsyncOperation ( ) ;
215
206
}
216
207
217
208
public override IAsyncOperation < IRandomAccessStream > OpenAsync ( FileAccessMode accessMode , StorageOpenOptions options ) => OpenAsync ( accessMode ) ;
@@ -226,11 +217,8 @@ public override IAsyncOperation<IRandomAccessStreamWithContentType> OpenReadAsyn
226
217
227
218
public override IAsyncOperation < IInputStream > OpenSequentialReadAsync ( )
228
219
{
229
- return AsyncInfo . Run ( async ( cancellationToken ) =>
230
- {
231
- var hFile = NativeFileOperationsHelper . OpenFileForRead ( Path ) ;
232
- return new FileStream ( hFile , FileAccess . Read ) . AsInputStream ( ) ;
233
- } ) ;
220
+ var hFile = NativeFileOperationsHelper . OpenFileForRead ( Path ) ;
221
+ return Task . FromResult ( new FileStream ( hFile , FileAccess . Read ) . AsInputStream ( ) ) . AsAsyncOperation ( ) ;
234
222
}
235
223
236
224
public override IAsyncOperation < StorageStreamTransaction > OpenTransactedWriteAsync ( )
@@ -272,4 +260,4 @@ public override IAsyncAction RenameAsync(string desiredName, NameCollisionOption
272
260
public override IAsyncOperation < StorageFile > ToStorageFileAsync ( )
273
261
=> throw new NotSupportedException ( ) ;
274
262
}
275
- }
263
+ }
0 commit comments