Esempio n. 1
0
        public static void WriteBytes(byte[] vs, string filePath, FileOperater operater = default)
        {
            FileOperater    fileOperater    = (operater == null) ? new FileOperater() : operater;
            FileCommandInfo fileCommandInfo = new FileCommandInfo
            {
                FileFullName = filePath,
                FileReadType = FileCommandInfo.FileCommandInfoReadType.Bytes,
                DataBytes    = vs
            };

            fileOperater.WriteFile(ref fileCommandInfo);
            fileCommandInfo.Dispose();
        }
Esempio n. 2
0
        public static void WriteUTF8Text(string content, string filePath, FileOperater operater = default)
        {
            FileOperater    fileOperater    = (operater == null) ? new FileOperater() : operater;
            FileCommandInfo fileCommandInfo = new FileCommandInfo
            {
                FileFullName = filePath,
                FileReadType = FileCommandInfo.FileCommandInfoReadType.Bytes,
                DataBytes    = Encoding.UTF8.GetBytes(content)
            };

            fileOperater.WriteFile(ref fileCommandInfo);
            fileCommandInfo.Dispose();
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public static void WriteBytes(string content, string filePath, FileOperater operater = default)
 {
     byte[] vs = Encoding.UTF8.GetBytes(content);
     WriteBytes(vs, filePath, operater);
 }