@@ -125,10 +125,7 @@ public override IAsyncAction DeleteAsync(StorageDeleteOption option)
125125
126126 public override IAsyncOperation < BaseBasicProperties > GetBasicPropertiesAsync ( )
127127 {
128- return AsyncInfo . Run ( async ( cancellationToken ) =>
129- {
130- return new BaseBasicProperties ( ) ;
131- } ) ;
128+ return Task . FromResult ( new BaseBasicProperties ( ) ) . AsAsyncOperation ( ) ;
132129 }
133130
134131 public override IAsyncOperation < BaseStorageFolder > GetParentAsync ( )
@@ -145,16 +142,13 @@ public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Thumbnai
145142
146143 public static IAsyncOperation < BaseStorageFile > FromPathAsync ( string path )
147144 {
148- return AsyncInfo . Run < BaseStorageFile > ( async ( cancellationToken ) =>
145+ if ( IsNativePath ( path ) && CheckAccess ( path ) )
149146 {
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+ }
158152
159153 private static bool CheckAccess ( string path )
160154 {
@@ -207,11 +201,8 @@ public override IAsyncAction MoveAsync(IStorageFolder destinationFolder, string
207201
208202 public override IAsyncOperation < IRandomAccessStream > OpenAsync ( FileAccessMode accessMode )
209203 {
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 ( ) ;
215206 }
216207
217208 public override IAsyncOperation < IRandomAccessStream > OpenAsync ( FileAccessMode accessMode , StorageOpenOptions options ) => OpenAsync ( accessMode ) ;
@@ -226,11 +217,8 @@ public override IAsyncOperation<IRandomAccessStreamWithContentType> OpenReadAsyn
226217
227218 public override IAsyncOperation < IInputStream > OpenSequentialReadAsync ( )
228219 {
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 ( ) ;
234222 }
235223
236224 public override IAsyncOperation < StorageStreamTransaction > OpenTransactedWriteAsync ( )
@@ -272,4 +260,4 @@ public override IAsyncAction RenameAsync(string desiredName, NameCollisionOption
272260 public override IAsyncOperation < StorageFile > ToStorageFileAsync ( )
273261 => throw new NotSupportedException ( ) ;
274262 }
275- }
263+ }
0 commit comments