Change the result value of Compress( ) and delete some comments
This commit is contained in:
parent
1828f5acbb
commit
78c31ad6c5
@ -81,9 +81,9 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
|
||||
origFile.CopyTo(compressor);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Source Code/TeamHobby.Main/archiving2.txt.gz
Normal file
BIN
Source Code/TeamHobby.Main/archiving2.txt.gz
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user