-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the FileInfo Extensions (#14888)
- Loading branch information
1 parent
1469439
commit dc7cc46
Showing
1 changed file
with
15 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
namespace OrchardCore.Tests.Utilities | ||
namespace OrchardCore.Tests.Utilities; | ||
|
||
public static class FileInfoExtensions | ||
{ | ||
public static class FileInfoExtensions | ||
public static string ReadToEnd(this IFileInfo fileInfo) | ||
{ | ||
public static string ReadToEnd(this IFileInfo fileInfo) | ||
=> ReadToEndAsync(fileInfo).GetAwaiter().GetResult(); | ||
using var stream = fileInfo.CreateReadStream(); | ||
|
||
using var streamReader = new StreamReader(stream); | ||
|
||
public static async Task<string> ReadToEndAsync(this IFileInfo fileInfo) | ||
{ | ||
await using var stream = fileInfo.CreateReadStream(); | ||
return streamReader.ReadToEnd(); | ||
} | ||
|
||
public static async Task<string> ReadToEndAsync(this IFileInfo fileInfo) | ||
{ | ||
await using var stream = fileInfo.CreateReadStream(); | ||
|
||
using var streamReader = new StreamReader(stream); | ||
using var streamReader = new StreamReader(stream); | ||
|
||
return await streamReader.ReadToEndAsync(); | ||
} | ||
return await streamReader.ReadToEndAsync(); | ||
} | ||
} |