using (FileStream inFile = fi.OpenRead())
{
// Prevent compressing hidden and already compressed files.
if ((File.GetAttributes(fi.FullName) & FileAttributes.Hidden)
!= FileAttributes.Hidden & fi.Extension != ".zip")
{
// Create the compressed file.
using (FileStream outFile = File.Create(fi.FullName + ".zip"))
{
using (GZipStream Compress = new GZipStream(outFile,
CompressionMode.Compress))
{
// Copy the source file into the compression stream.
byte[] buffer = new byte[4096];
int numRead;
while ((numRead = inFile.Read(buffer, 0, buffer.Length)) != 0)
{
Compress.Write(buffer, 0, numRead);
}
Console.WriteLine("Compressed {0} from {1} to {2} bytes.",
fi.Name, fi.Length.ToString(), outFile.Length.ToString());
}
}
}
}
Monday, April 5, 2010
Subscribe to:
Post Comments (Atom)
2 comments:
POINTER
1) Its not necessary to initialize the pointer at the time of declaration. Like
int a = 10;
int *P = &a; //It is not necessary
Another way is :
int a = 10;
int *P;
P = &a;
2) You can create the array of Pointer.
3) You can assign NULL to the pointer like
int *P = NULL; //Valid
4) You can use pointer to pointer.
REFERENCE
1) Its necessary to initialize the Reference at the time of declaration. Like
int &a = 10;
int &a; //Error here but not in case of Pointer.
2) You can not create the Array of reference.
3) You can not assign NULL to the reference like
int &a = NULL; //Error
4) You can not use reference to reference.
POINTER
1) Its not necessary to initialize the pointer at the time of declaration. Like
int a = 10;
int *P = &a; //It is not necessary
Another way is :
int a = 10;
int *P;
P = &a;
2) You can create the array of Pointer.
3) You can assign NULL to the pointer like
int *P = NULL; //Valid
4) You can use pointer to pointer.
REFERENCE
1) Its necessary to initialize the Reference at the time of declaration. Like
int &a = 10;
int &a; //Error here but not in case of Pointer.
2) You can not create the Array of reference.
3) You can not assign NULL to the reference like
int &a = NULL; //Error
4) You can not use reference to reference.
Post a Comment