コード例 #1
0
        public static byte[] ReadBytes(string filePath, FileOperater operater = default)
        {
            FileOperater    fileOperater    = (operater == null) ? new FileOperater() : operater;
            FileCommandInfo fileCommandInfo = new FileCommandInfo
            {
                FileFullName = filePath,
                FileReadType = FileCommandInfo.FileCommandInfoReadType.Bytes
            };

            fileOperater.ReadFile(ref fileCommandInfo);

            byte[] bytes = fileCommandInfo.DataBytes;
            fileCommandInfo.Dispose();

            return(bytes);
        }
コード例 #2
0
        public static string ReadUTF8Text(string filePath, FileOperater operater = null)
        {
            FileOperater    fileOperater    = (operater == null) ? new FileOperater() : operater;
            FileCommandInfo fileCommandInfo = new FileCommandInfo
            {
                FileFullName = filePath,
                FileReadType = FileCommandInfo.FileCommandInfoReadType.Bytes
            };

            fileOperater.ReadFile(ref fileCommandInfo);

            byte[] bytes  = fileCommandInfo.DataBytes;
            string result = (bytes == null) ? string.Empty : Encoding.UTF8.GetString(bytes);

            fileCommandInfo.Dispose();

            return(result);
        }