DevTreks.Data/Helpers/FileIO.cs
/// <summary>
/// This does not includes a try catch block
/// </summary>
/// <param name="filePath">path to file being read</param>
/// <returns>string holding file contents</returns>
This does not includes a try catch block
This does not includes a try catch block
public async Task<string> ReadTextAsync2(string filePath)
        {
            string sFile = string.Empty;
            using (FileStream sourceStream = new FileStream(filePath,
              FileMode.Open, FileAccess.Read, FileShare.Read,
              bufferSize: 4096, useAsync: true))
            {
                byte[] buffer = new byte[sourceStream.Length];
                int bytes = await sourceStream.ReadAsync(buffer, 0, (int)sourceStream.Length);
                sFile = Encoding.UTF8.GetString(buffer, 0, buffer.Length);
            }
            return sFile;
        }
public async Task < string > ReadTextAsync2 ( string filePath ) { string sFile = string . Empty ; using ( FileStream sourceStream = new FileStream ( filePath , FileMode . Open , FileAccess . Read , FileShare . Read , bufferSize : 4096 , useAsync : true ) ) { byte [ ] buffer = new byte [ sourceStream . Length ] ; int bytes = await sourceStream . ReadAsync ( buffer , 0 , ( int ) sourceStream . Length ) ; sFile = Encoding . UTF8 . GetString ( buffer , 0 , buffer . Length ) ; } return sFile ; }
This does not includes a try catch block
This does not includes a try catch block
//this returns tab return characters \r and newline \chars that is inconsistent with new line \n chars in non async //bytes = buffer.length
string holding file contents
string holding file contents
filePath
string
path to file being read
path to file being read