@@ -92,7 +92,7 @@ public static List<PathBoxItem> GetDirectoryPathComponents(string value)
9292 return pathBoxItems ;
9393 }
9494
95- public async static Task < StorageFolderWithPath > DangerousGetFolderWithPathFromPathAsync ( string value , StorageFolderWithPath rootFolder = null , StorageFolderWithPath parentFolder = null )
95+ public async static Task < IStorageFolder > DangerousGetFolderWithPathFromPathAsync ( string value , IStorageFolder rootFolder = null , IStorageFolder parentFolder = null )
9696 {
9797 if ( rootFolder != null )
9898 {
@@ -104,123 +104,101 @@ public async static Task<StorageFolderWithPath> DangerousGetFolderWithPathFromPa
104104 }
105105 else if ( parentFolder != null && value . IsSubPathOf ( parentFolder . Path ) )
106106 {
107- var folder = parentFolder . Folder ;
107+ var folder = parentFolder ;
108108 var prevComponents = GetDirectoryPathComponents ( parentFolder . Path ) ;
109- var path = parentFolder . Path ;
110109 foreach ( var component in currComponents . ExceptBy ( prevComponents , c => c . Path ) )
111110 {
112111 folder = await folder . GetFolderAsync ( component . Title ) ;
113- path = Path . Combine ( path , folder . Name ) ;
114112 }
115- return new StorageFolderWithPath ( folder , path ) ;
113+ return folder ;
116114 }
117115 else if ( value . IsSubPathOf ( rootFolder . Path ) )
118116 {
119- var folder = rootFolder . Folder ;
120- var path = rootFolder . Path ;
117+ var folder = rootFolder ;
121118 foreach ( var component in currComponents . Skip ( 1 ) )
122119 {
123120 folder = await folder . GetFolderAsync ( component . Title ) ;
124- path = Path . Combine ( path , folder . Name ) ;
125121 }
126- return new StorageFolderWithPath ( folder , path ) ;
122+ return folder ;
127123 }
128124 }
129125
130126 if ( parentFolder != null && ! Path . IsPathRooted ( value ) )
131127 {
132128 // Relative path
133129 var fullPath = Path . GetFullPath ( Path . Combine ( parentFolder . Path , value ) ) ;
134- return new StorageFolderWithPath ( await StorageFolder . GetFolderFromPathAsync ( fullPath ) ) ;
130+ return await StorageFolder . GetFolderFromPathAsync ( fullPath ) ;
135131 }
136132 else
137133 {
138- return new StorageFolderWithPath ( await StorageFolder . GetFolderFromPathAsync ( value ) ) ;
134+ return await StorageFolder . GetFolderFromPathAsync ( value ) ;
139135 }
140136 }
141137
142- public async static Task < StorageFolder > DangerousGetFolderFromPathAsync ( string value ,
143- StorageFolderWithPath rootFolder = null ,
144- StorageFolderWithPath parentFolder = null )
138+ public async static Task < IStorageFolder > DangerousGetFolderFromPathAsync ( string value ,
139+ IStorageFolder rootFolder = null ,
140+ IStorageFolder parentFolder = null )
145141 {
146- return ( await DangerousGetFolderWithPathFromPathAsync ( value , rootFolder , parentFolder ) ) . Folder ;
142+ return await DangerousGetFolderWithPathFromPathAsync ( value , rootFolder , parentFolder ) ;
147143 }
148144
149- public async static Task < StorageFileWithPath > DangerousGetFileWithPathFromPathAsync ( string value ,
150- StorageFolderWithPath rootFolder = null ,
151- StorageFolderWithPath parentFolder = null )
145+ public async static Task < IStorageFile > DangerousGetFileWithPathFromPathAsync ( string value ,
146+ IStorageFolder rootFolder = null ,
147+ IStorageFolder parentFolder = null )
152148 {
153149 if ( rootFolder != null )
154150 {
155151 var currComponents = GetDirectoryPathComponents ( value ) ;
156152
157153 if ( parentFolder != null && value . IsSubPathOf ( parentFolder . Path ) )
158154 {
159- var folder = parentFolder . Folder ;
155+ var folder = parentFolder ;
160156 var prevComponents = GetDirectoryPathComponents ( parentFolder . Path ) ;
161- var path = parentFolder . Path ;
162157 foreach ( var component in currComponents . ExceptBy ( prevComponents , c => c . Path ) . SkipLast ( 1 ) )
163158 {
164159 folder = await folder . GetFolderAsync ( component . Title ) ;
165- path = Path . Combine ( path , folder . Name ) ;
166160 }
167161 var file = await folder . GetFileAsync ( currComponents . Last ( ) . Title ) ;
168- path = Path . Combine ( path , file . Name ) ;
169- return new StorageFileWithPath ( file , path ) ;
162+ return file ;
170163 }
171164 else if ( value . IsSubPathOf ( rootFolder . Path ) )
172165 {
173- var folder = rootFolder . Folder ;
174- var path = rootFolder . Path ;
166+ var folder = rootFolder ;
175167 foreach ( var component in currComponents . Skip ( 1 ) . SkipLast ( 1 ) )
176168 {
177169 folder = await folder . GetFolderAsync ( component . Title ) ;
178- path = Path . Combine ( path , folder . Name ) ;
179170 }
180171 var file = await folder . GetFileAsync ( currComponents . Last ( ) . Title ) ;
181- path = Path . Combine ( path , file . Name ) ;
182- return new StorageFileWithPath ( file , path ) ;
172+ return file ;
183173 }
184174 }
185175
186176 if ( parentFolder != null && ! Path . IsPathRooted ( value ) )
187177 {
188178 // Relative path
189179 var fullPath = Path . GetFullPath ( Path . Combine ( parentFolder . Path , value ) ) ;
190- return new StorageFileWithPath ( await StorageFile . GetFileFromPathAsync ( fullPath ) ) ;
180+ return await StorageFile . GetFileFromPathAsync ( fullPath ) ;
191181 }
192182 else
193183 {
194- return new StorageFileWithPath ( await StorageFile . GetFileFromPathAsync ( value ) ) ;
184+ return await StorageFile . GetFileFromPathAsync ( value ) ;
195185 }
196186 }
197187
198- public async static Task < StorageFile > DangerousGetFileFromPathAsync ( string value ,
199- StorageFolderWithPath rootFolder = null ,
200- StorageFolderWithPath parentFolder = null )
188+ public async static Task < IStorageFile > DangerousGetFileFromPathAsync ( string value ,
189+ IStorageFolder rootFolder = null ,
190+ IStorageFolder parentFolder = null )
201191 {
202- return ( await DangerousGetFileWithPathFromPathAsync ( value , rootFolder , parentFolder ) ) . File ;
192+ return await DangerousGetFileWithPathFromPathAsync ( value , rootFolder , parentFolder ) ;
203193 }
204194
205- public async static Task < IList < StorageFolderWithPath > > GetFoldersWithPathAsync ( this StorageFolderWithPath parentFolder , uint maxNumberOfItems = uint . MaxValue )
206- {
207- return ( await parentFolder . Folder . GetFoldersAsync ( CommonFolderQuery . DefaultQuery , 0 , maxNumberOfItems ) )
208- . Select ( x => new StorageFolderWithPath ( x , Path . Combine ( parentFolder . Path , x . Name ) ) ) . ToList ( ) ;
209- }
210-
211- public async static Task < IList < StorageFileWithPath > > GetFilesWithPathAsync ( this StorageFolderWithPath parentFolder , uint maxNumberOfItems = uint . MaxValue )
212- {
213- return ( await parentFolder . Folder . GetFilesAsync ( CommonFileQuery . DefaultQuery , 0 , maxNumberOfItems ) )
214- . Select ( x => new StorageFileWithPath ( x , Path . Combine ( parentFolder . Path , x . Name ) ) ) . ToList ( ) ;
215- }
216-
217- public async static Task < IList < StorageFolderWithPath > > GetFoldersWithPathAsync ( this StorageFolderWithPath parentFolder , string nameFilter , uint maxNumberOfItems = uint . MaxValue )
195+ public async static Task < IList < StorageFolder > > GetFoldersWithPathAsync ( this StorageFolder parentFolder , string nameFilter , uint maxNumberOfItems = uint . MaxValue )
218196 {
219197 var queryOptions = new QueryOptions ( ) ;
220198 queryOptions . ApplicationSearchFilter = $ "System.FileName:{ nameFilter } *";
221- StorageFolderQueryResult queryResult = parentFolder . Folder . CreateFolderQueryWithOptions ( queryOptions ) ;
199+ StorageFolderQueryResult queryResult = parentFolder . CreateFolderQueryWithOptions ( queryOptions ) ;
222200
223- return ( await queryResult . GetFoldersAsync ( 0 , maxNumberOfItems ) ) . Select ( x => new StorageFolderWithPath ( x , Path . Combine ( parentFolder . Path , x . Name ) ) ) . ToList ( ) ;
201+ return ( await queryResult . GetFoldersAsync ( 0 , maxNumberOfItems ) ) . ToList ( ) ;
224202 }
225203
226204 public static string GetPathWithoutEnvironmentVariable ( string path )
0 commit comments