static private InternalOpen ( string path, int bufferSize = DefaultBufferSize, bool useAsync = DefaultIsAsync ) : |
||
path | string | |
bufferSize | int | |
useAsync | bool | |
Результат |
private static byte[] InternalReadAllBytes(String path) { // bufferSize == 1 used to avoid unnecessary buffer in FileStream using (FileStream fs = FileStream.InternalOpen(path, bufferSize: 1, useAsync: false)) { long fileLength = fs.Length; if (fileLength > Int32.MaxValue) { throw new IOException(SR.IO_FileTooLong2GB); } int index = 0; int count = (int)fileLength; byte[] bytes = new byte[count]; while (count > 0) { int n = fs.Read(bytes, index, count); if (n == 0) { throw __Error.GetEndOfFile(); } index += n; count -= n; } return(bytes); } }
private static String InternalReadAllText(String path, Encoding encoding) { Contract.Requires(path != null); Contract.Requires(encoding != null); Contract.Requires(path.Length > 0); Stream stream = FileStream.InternalOpen(path, useAsync: false); using (StreamReader sr = new StreamReader(stream, encoding, true)) return(sr.ReadToEnd()); }
public static StreamReader OpenText(String path) { if (path == null) { throw new ArgumentNullException("path"); } Contract.EndContractBlock(); Stream stream = FileStream.InternalOpen(path); return(new StreamReader(stream)); }
private static String[] InternalReadAllLines(String path, Encoding encoding) { Contract.Requires(path != null); Contract.Requires(encoding != null); Contract.Requires(path.Length != 0); String line; List <String> lines = new List <String>(); Stream stream = FileStream.InternalOpen(path, useAsync: false); using (StreamReader sr = new StreamReader(stream, encoding)) while ((line = sr.ReadLine()) != null) { lines.Add(line); } return(lines.ToArray()); }
private static ReadLinesIterator CreateIterator(string path, Encoding encoding, StreamReader reader) { Stream stream = FileStream.InternalOpen(path); return(new ReadLinesIterator(path, encoding, reader ?? new StreamReader(stream, encoding))); }
private static ReadLinesIterator CreateIterator(string path, Encoding encoding, StreamReader reader) { return(new ReadLinesIterator(path, encoding, reader ?? new StreamReader(FileStream.InternalOpen(path, useAsync: false), encoding))); }
[System.Security.SecuritySafeCritical] // auto-generated public StreamReader OpenText() { Stream stream = FileStream.InternalOpen(FullPath); return(new StreamReader(stream, Encoding.UTF8, true)); }