From b591a55bf28c3f7c829b35336d4920610d6d3599 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Mon, 30 Mar 2020 20:52:11 +0300 Subject: [PATCH] Add ReadFileWithoutBom to get content when the file encoded with Byte Order Mark. --- .../src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs index 4c258dfbeb..a945784352 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs @@ -4,6 +4,7 @@ using System.IO; using System.Text; using System.Threading.Tasks; using JetBrains.Annotations; +using Volo.Abp.Text; namespace Volo.Abp.IO { @@ -120,5 +121,17 @@ namespace Volo.Abp.IO return lines.ToArray(); } + + /// + /// Opens a text file, reads content without BOM + /// + /// The file to open for reading. + /// A string containing all lines of the file. + public static async Task ReadFileWithoutBomAsync(string path) + { + var content = await ReadAllBytesAsync(path); + + return StringHelper.ConvertFromBytesWithoutBom(content); + } } } \ No newline at end of file