Simply replace the whole thing with:
return File.ReadAllBytes(fileName);
However, if you are concerned about the memory consumption, you should not read the whole file into memory all at once at all. You should do that in chunks.
More Related Contents:
- How do I convert an array of floats to a byte[] and back?
- Error” Parameter is not valid ” while converting Bytes into Image
- Can you call Directory.GetFiles() with multiple filters?
- Easiest way to read from and write to files
- How to check for file lock? [duplicate]
- What is the ‘dynamic’ type in C# 4.0 used for?
- execute c# code at runtime from code file
- C# List Sort by x then y
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug
- Request.UrlReferrer null?
- A dictionary object that uses ranges of values for keys
- The State of Linkers for .NET apps (aka “Please Sir, May I have a Linker” 2009 edition)
- How to Combine two lambdas [duplicate]
- thread with multiple parameters
- How to inject an attribute using a PostSharp attribute?
- WebClient runs javascript
- Why can I use a collection initializer with private set access from another class?
- Lock (Monitor) internal implementation in .NET
- How can I include line numbers in a stack trace without a pdb?
- Data binding for TextBox
- How to specify data attributes in razor, e.g., data-externalid=”23151″ on @this.Html.CheckBoxFor(…)
- Create object instance of a class from its name in string variable
- Method to determine if path string is local or remote machine
- How do I mock User.Identity.GetUserId()?
- Azure Blob Storage | AcquireLeaseAsync, synchronously wait until lock is released
- When is the best place to use Task.Result instead of awaiting Task
- Which objects can I use in a finalizer method?
- Formatting Large Numbers with .NET
- Can I reuse HttpWebRequest without disconnecting from the server?