Change the result value of Compress( ) and delete some comments

This commit is contained in:
Lunastra 2021-12-04 18:40:19 -08:00
parent 1828f5acbb
commit 78c31ad6c5
3 changed files with 6 additions and 36 deletions

View File

@ -81,9 +81,9 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
origFile.CopyTo(compressor);
return true;
}
}
return true;
return false;
}
catch (Exception ex)
{

View File

@ -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";
}
}

Binary file not shown.