Skip to content

Commit

Permalink
Fix FromFile
Browse files Browse the repository at this point in the history
  • Loading branch information
engineering87 committed Oct 6, 2024
1 parent ff6fbf4 commit bf29712
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions SharpHelpers/SharpHelpers/StreamHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,17 @@ public static bool ToFile(this Stream stream, string fileName, bool overrideExis
{
return false;
}
}

}

/// <summary>
/// Loads a stream from a file
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static Stream FromFile(string fileName)
{
var fileStream = File.OpenRead(fileName);
var fileLength = (int)fileStream.Length;
var fileBytes = new byte[fileLength];
fileStream.Read(fileBytes, 0, fileLength);
fileStream.Close();
fileStream.Dispose();
return FromArray(fileBytes);
public static Stream FromFile(this string fileName)
{
byte[] fileBytes = File.ReadAllBytes(fileName);
return FromArray(fileBytes);
}
}
}

0 comments on commit bf29712

Please sign in to comment.