private static TDataType[,] StreamReadData <TDataType>(string filePath, uint startRow, uint[] columns, uint lineCount, Encoding encoding) { StreamReader reader = null; try { if (0 >= lineCount) { lineCount = FileUtil.GetFileLineNum(filePath) - startRow; } FileUtil.InitReadStream(ref reader, filePath, encoding); return(FileUtil.StreamReadFromStrFile <TDataType>(reader, lineCount, Delims, startRow, columns)); } catch (SeeSharpFileException) { throw; } catch (ApplicationException ex) { throw new SeeSharpFileException(SeeSharpFileErrorCode.RuntimeError, i18n.GetFStr("Runtime.ReadFail", ex.Message), ex); } finally { FileUtil.ReleaseResource(reader); } }
private static TDataType[,] StreamReadData <TDataType>(string filePath, long[] rows, long[] columns, Encoding encoding) { StreamReader reader = null; uint rowCount = (uint)rows.Length; //行数 uint columnCount = (uint)rows.Length; //列数 try { if (0 >= rowCount) { //如果行数为0,则读取全部,即文件的总行数-起始行 rowCount = FileUtil.GetFileLineNum(filePath); for (int i = 0; i < rowCount; i++) { rows[i] = i; } } FileUtil.InitReadStream(ref reader, filePath, encoding);//获取文件中所有数据在reader里 return(FileUtil.StreamReadFromStrFile <TDataType>(reader, rows, columns, Delims)); } catch (SeeSharpFileException) { throw; } catch (ApplicationException ex) { throw new SeeSharpFileException(SeeSharpFileErrorCode.RuntimeError, i18n.GetFStr("Runtime.ReadFail", ex.Message), ex); } finally { FileUtil.ReleaseResource(reader); } }
private static TDataType[,] StreamReadData <TDataType>(string filePath, long startRow, long startColumn, long rowCount, long columnCount, Encoding encoding) { StreamReader reader = null; try { if (0 >= rowCount) { //如果行数为0,则读取全部,即文件的总行数-起始行 rowCount = FileUtil.GetFileLineNum(filePath) - startRow; } FileUtil.InitReadStream(ref reader, filePath, encoding);//获取文件中所有数据在reader里 return(FileUtil.StreamReadFromStrFile <TDataType>(reader, startRow, startColumn, rowCount, columnCount, Delims)); } catch (SeeSharpFileException) { throw; } catch (ApplicationException ex) { throw new SeeSharpFileException(SeeSharpFileErrorCode.RuntimeError, i18n.GetFStr("Runtime.ReadFail", ex.Message), ex); } finally { FileUtil.ReleaseResource(reader); } }
private static TDataType[] StreamReadData <TDataType>(string filePath, long index, long startIndex, long size, bool majorOrder, Encoding encoding) { StreamReader reader = null; try { if (majorOrder == false) { FileUtil.InitReadStream(ref reader, filePath, encoding);//获取文件中所有数据在reader里 TDataType[] data = FileUtil.StreamReadFromStrFile <TDataType>(reader, index, startIndex, size, majorOrder, Delims); return(data); } else { //如果行数为-1,则读取全部,即文件的总行数-起始行 if (size <= 0) { size = FileUtil.GetFileLineNum(filePath); } FileUtil.InitReadStream(ref reader, filePath, encoding);//获取文件中所有数据在reader里 TDataType[] data = FileUtil.StreamReadFromStrFile <TDataType>(reader, index, startIndex, size, majorOrder, Delims); return(data); } } catch (SeeSharpFileException) { throw; } catch (ApplicationException ex) { throw new SeeSharpFileException(SeeSharpFileErrorCode.RuntimeError, i18n.GetFStr("Runtime.ReadFail", ex.Message), ex); } finally { FileUtil.ReleaseResource(reader); } }