Browse Source

Add ReadFileWithoutBom to get content when the file encoded with Byte Order Mark.

pull/3421/head
Alper Ebicoglu 7 years ago
parent
commit
b591a55bf2
  1. 13
      framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs

13
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();
}
/// <summary>
/// Opens a text file, reads content without BOM
/// </summary>
/// <param name="path">The file to open for reading.</param>
/// <returns>A string containing all lines of the file.</returns>
public static async Task<string> ReadFileWithoutBomAsync(string path)
{
var content = await ReadAllBytesAsync(path);
return StringHelper.ConvertFromBytesWithoutBom(content);
}
}
}
Loading…
Cancel
Save