From 78c31ad6c5569afc034ef214061a36f566abe522 Mon Sep 17 00:00:00 2001 From: Lunastra Date: Sat, 4 Dec 2021 18:40:19 -0800 Subject: [PATCH] Change the result value of Compress( ) and delete some comments --- .../Implementations/SQLSource.cs | 4 +- Source Code/TeamHobby.Main/HobbyMain.cs | 38 ++---------------- Source Code/TeamHobby.Main/archiving2.txt.gz | Bin 0 -> 440 bytes 3 files changed, 6 insertions(+), 36 deletions(-) create mode 100644 Source Code/TeamHobby.Main/archiving2.txt.gz diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs index ab5b34a..c445c06 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs @@ -81,9 +81,9 @@ namespace TeamHobby.HobbyProjectGenerator.Archive origFile.CopyTo(compressor); return true; - } + } - return true; + return false; } catch (Exception ex) { diff --git a/Source Code/TeamHobby.Main/HobbyMain.cs b/Source Code/TeamHobby.Main/HobbyMain.cs index 6d30a27..3d20ec8 100644 --- a/Source Code/TeamHobby.Main/HobbyMain.cs +++ b/Source Code/TeamHobby.Main/HobbyMain.cs @@ -16,47 +16,17 @@ public class HobbyMain Console.WriteLine("File Name: {0}", fileInfo.FullName); - //Console.WriteLine("Starting file compression: "); - //Compress(fileInfo); - //Console.WriteLine("Ending compression"); - //SqlConnection myconn = new SqlConnection(); - - - //IDataSource dataSource = new SQLSource(); - SQLSource sqlSource = new SQLSource(); bool res = sqlSource.CompressFile(fileName); //bool res = CompressFile(fileName); Console.WriteLine(res); + Console.WriteLine(CreateFileName()); } - - - public static void Compress(FileInfo fi) + + public static string CreateFileName() { - // Get the stream of the source file. - using (FileStream inFile = fi.OpenRead()) - { - // Prevent compressing hidden and - // already compressed files. - if ((File.GetAttributes(fi.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fi.Extension != ".gz") - { - // Create the compressed file. - using (FileStream outFile = - File.Create(fi.FullName + ".gz")) - { - using (GZipStream Compress = new GZipStream(outFile, CompressionMode.Compress)) - { - // Copy the source file into - // the compression stream. - inFile.CopyTo(Compress); - - Console.WriteLine("Compressed {0} from {1} to {2} bytes.", - fi.Name, fi.Length.ToString(), outFile.Length.ToString()); - } - } - } - } + return DateTime.Now.ToString() + "archive.txt"; } } diff --git a/Source Code/TeamHobby.Main/archiving2.txt.gz b/Source Code/TeamHobby.Main/archiving2.txt.gz new file mode 100644 index 0000000000000000000000000000000000000000..d79034a2e507a9ef9ad54f20dd3f7969d84cbc88 GIT binary patch literal 440 zcmV;p0Z0BHiwFP!000003WZcnPs1<_y-(VIu*9X4=mgh_O@fXgq=5tzH!dObx=39z zCEh0fJt_TIlBRHL{p{!GSGy#rMEEcWIWw5Sz2-Y{60#VN#-jt%B)B**NezIxlB88x zqMmZ&XDk>o3rplAlTg)u!DxM? z^iy&r4e4X`J|N{TP5WJ47lL^LBLdX%!dZ=2<8$j4d%C1*H=^qbtuM}O<58*90j^3>?C7gJBAj=^UZ$nB zC@ZOf3XLdXQ#mu6!R_E;M3=H1a%-8ZsbSVea*dX9*~Al=3=&^NXLfvoT