Skip to content

Commit bf97b45

Browse files
committed
Readded SaveFileAsync to match previous implementation
1 parent 7edade1 commit bf97b45

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Microsoft.Toolkit.Uwp/Helpers/ObjectStorage/ApplicationDataStorageHelper.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public Task<IList<Tuple<DirectoryItemType, string>>> ReadFolderAsync(string fold
184184
/// <inheritdoc />
185185
public Task CreateFileAsync<T>(string filePath, T value)
186186
{
187-
return CreateFileAsync<T>(DefaultFolder, filePath, value);
187+
return SaveFileAsync<T>(DefaultFolder, filePath, value);
188188
}
189189

190190
/// <inheritdoc />
@@ -211,6 +211,18 @@ public Task<bool> FileExistsAsync(string fileName, bool isRecursive = false)
211211
return FileExistsAsync(DefaultFolder, fileName, isRecursive);
212212
}
213213

214+
/// <summary>
215+
/// Saves an object inside a file.
216+
/// </summary>
217+
/// <typeparam name="T">Type of object saved.</typeparam>
218+
/// <param name="filePath">Path to the file that will contain the object.</param>
219+
/// <param name="value">Object to save.</param>
220+
/// <returns>Waiting task until completion.</returns>
221+
public Task<StorageFile> SaveFileAsync<T>(string filePath, T value)
222+
{
223+
return SaveFileAsync<T>(DefaultFolder, filePath, value);
224+
}
225+
214226
private async Task<bool> ItemExistsAsync(StorageFolder folder, string itemName)
215227
{
216228
var item = await folder.TryGetItemAsync(itemName);
@@ -243,7 +255,7 @@ private async Task<IList<Tuple<DirectoryItemType, string>>> ReadFolderAsync(Stor
243255
}).ToList();
244256
}
245257

246-
private Task CreateFileAsync<T>(StorageFolder folder, string filePath, T value)
258+
private Task<StorageFile> SaveFileAsync<T>(StorageFolder folder, string filePath, T value)
247259
{
248260
return StorageFileHelper.WriteTextToFileAsync(folder, _serializer.Serialize(value)?.ToString(), filePath, CreationCollisionOption.ReplaceExisting);
249261
}

0 commit comments

Comments
 (0)