Example #1
0
        public static byte[] ReadAllBytes(string filePath, string fileName, FileExtensions extension)
        {
            string path = string.Empty;

            if (extension == FileExtensions.sec)
            {
                path = ((string.IsNullOrEmpty(filePath) == false) ? (filePath + "\\") : "") + fileName + "." + FileExtensions.dat.ToString();
                return(AesFileEncryptionPrivider.ReadFile(path));
            }
            path = ((string.IsNullOrEmpty(filePath) == false) ? (filePath + "\\") : "") + fileName + "." + extension.ToString();
            return(System.IO.File.ReadAllBytes(path));
        }
Example #2
0
        //public static async Task<byte[]> ReadAllBytesAsync(string filePath, string fileName, FileExtensions extension)
        //{
        //    string path = ((string.IsNullOrEmpty(filePath) == false) ? (filePath + "\\") : "") + fileName + "." + extension.ToString();
        //    return await Task.Run(() => System.IO.File.ReadAllBytes(path));
        //}
        //public static async Task<byte[]> ReadAllBytesAsync(string fileName, FileExtensions extension)
        //{
        //    return await ReadAllBytesAsync("", fileName, extension);
        //}
        #endregion

        #region write
        public static void WriteAllBytes(this byte[] file, string filePath, string fileName, FileExtensions extension)
        {
            string path = string.Empty;

            if (extension == FileExtensions.sec)
            {
                path = ((string.IsNullOrEmpty(filePath) == false) ? (filePath + "\\") : "") + fileName + "." + FileExtensions.dat.ToString();
                AesFileEncryptionPrivider.WriteFile(file, path);
            }
            else
            {
                path = ((string.IsNullOrEmpty(filePath) == false) ? (filePath + "\\") : "") + fileName + "." + extension.ToString();
                System.IO.File.WriteAllBytes(path, file);
            }
        }