@@ -92,7 +92,7 @@ public static List<PathBoxItem> GetDirectoryPathComponents(string value)
92
92
return pathBoxItems ;
93
93
}
94
94
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 )
96
96
{
97
97
if ( rootFolder != null )
98
98
{
@@ -104,123 +104,101 @@ public async static Task<StorageFolderWithPath> DangerousGetFolderWithPathFromPa
104
104
}
105
105
else if ( parentFolder != null && value . IsSubPathOf ( parentFolder . Path ) )
106
106
{
107
- var folder = parentFolder . Folder ;
107
+ var folder = parentFolder ;
108
108
var prevComponents = GetDirectoryPathComponents ( parentFolder . Path ) ;
109
- var path = parentFolder . Path ;
110
109
foreach ( var component in currComponents . ExceptBy ( prevComponents , c => c . Path ) )
111
110
{
112
111
folder = await folder . GetFolderAsync ( component . Title ) ;
113
- path = Path . Combine ( path , folder . Name ) ;
114
112
}
115
- return new StorageFolderWithPath ( folder , path ) ;
113
+ return folder ;
116
114
}
117
115
else if ( value . IsSubPathOf ( rootFolder . Path ) )
118
116
{
119
- var folder = rootFolder . Folder ;
120
- var path = rootFolder . Path ;
117
+ var folder = rootFolder ;
121
118
foreach ( var component in currComponents . Skip ( 1 ) )
122
119
{
123
120
folder = await folder . GetFolderAsync ( component . Title ) ;
124
- path = Path . Combine ( path , folder . Name ) ;
125
121
}
126
- return new StorageFolderWithPath ( folder , path ) ;
122
+ return folder ;
127
123
}
128
124
}
129
125
130
126
if ( parentFolder != null && ! Path . IsPathRooted ( value ) )
131
127
{
132
128
// Relative path
133
129
var fullPath = Path . GetFullPath ( Path . Combine ( parentFolder . Path , value ) ) ;
134
- return new StorageFolderWithPath ( await StorageFolder . GetFolderFromPathAsync ( fullPath ) ) ;
130
+ return await StorageFolder . GetFolderFromPathAsync ( fullPath ) ;
135
131
}
136
132
else
137
133
{
138
- return new StorageFolderWithPath ( await StorageFolder . GetFolderFromPathAsync ( value ) ) ;
134
+ return await StorageFolder . GetFolderFromPathAsync ( value ) ;
139
135
}
140
136
}
141
137
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 )
145
141
{
146
- return ( await DangerousGetFolderWithPathFromPathAsync ( value , rootFolder , parentFolder ) ) . Folder ;
142
+ return await DangerousGetFolderWithPathFromPathAsync ( value , rootFolder , parentFolder ) ;
147
143
}
148
144
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 )
152
148
{
153
149
if ( rootFolder != null )
154
150
{
155
151
var currComponents = GetDirectoryPathComponents ( value ) ;
156
152
157
153
if ( parentFolder != null && value . IsSubPathOf ( parentFolder . Path ) )
158
154
{
159
- var folder = parentFolder . Folder ;
155
+ var folder = parentFolder ;
160
156
var prevComponents = GetDirectoryPathComponents ( parentFolder . Path ) ;
161
- var path = parentFolder . Path ;
162
157
foreach ( var component in currComponents . ExceptBy ( prevComponents , c => c . Path ) . SkipLast ( 1 ) )
163
158
{
164
159
folder = await folder . GetFolderAsync ( component . Title ) ;
165
- path = Path . Combine ( path , folder . Name ) ;
166
160
}
167
161
var file = await folder . GetFileAsync ( currComponents . Last ( ) . Title ) ;
168
- path = Path . Combine ( path , file . Name ) ;
169
- return new StorageFileWithPath ( file , path ) ;
162
+ return file ;
170
163
}
171
164
else if ( value . IsSubPathOf ( rootFolder . Path ) )
172
165
{
173
- var folder = rootFolder . Folder ;
174
- var path = rootFolder . Path ;
166
+ var folder = rootFolder ;
175
167
foreach ( var component in currComponents . Skip ( 1 ) . SkipLast ( 1 ) )
176
168
{
177
169
folder = await folder . GetFolderAsync ( component . Title ) ;
178
- path = Path . Combine ( path , folder . Name ) ;
179
170
}
180
171
var file = await folder . GetFileAsync ( currComponents . Last ( ) . Title ) ;
181
- path = Path . Combine ( path , file . Name ) ;
182
- return new StorageFileWithPath ( file , path ) ;
172
+ return file ;
183
173
}
184
174
}
185
175
186
176
if ( parentFolder != null && ! Path . IsPathRooted ( value ) )
187
177
{
188
178
// Relative path
189
179
var fullPath = Path . GetFullPath ( Path . Combine ( parentFolder . Path , value ) ) ;
190
- return new StorageFileWithPath ( await StorageFile . GetFileFromPathAsync ( fullPath ) ) ;
180
+ return await StorageFile . GetFileFromPathAsync ( fullPath ) ;
191
181
}
192
182
else
193
183
{
194
- return new StorageFileWithPath ( await StorageFile . GetFileFromPathAsync ( value ) ) ;
184
+ return await StorageFile . GetFileFromPathAsync ( value ) ;
195
185
}
196
186
}
197
187
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 )
201
191
{
202
- return ( await DangerousGetFileWithPathFromPathAsync ( value , rootFolder , parentFolder ) ) . File ;
192
+ return await DangerousGetFileWithPathFromPathAsync ( value , rootFolder , parentFolder ) ;
203
193
}
204
194
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 )
218
196
{
219
197
var queryOptions = new QueryOptions ( ) ;
220
198
queryOptions . ApplicationSearchFilter = $ "System.FileName:{ nameFilter } *";
221
- StorageFolderQueryResult queryResult = parentFolder . Folder . CreateFolderQueryWithOptions ( queryOptions ) ;
199
+ StorageFolderQueryResult queryResult = parentFolder . CreateFolderQueryWithOptions ( queryOptions ) ;
222
200
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 ( ) ;
224
202
}
225
203
226
204
public static string GetPathWithoutEnvironmentVariable ( string path )
0 commit comments