Double extensions when compressing file with c# (*.GZip)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Charp
    New Member
    • Mar 2012
    • 5

    Double extensions when compressing file with c# (*.GZip)

    I have an application that saves data to a MS Access database and then compresses it. The annoyance here is that I get a double extension on my zip folder. (*.accdb.gz).

    I have come up with an alternative but it causes the compressed file to not get any extension at all. The problem is that I name both the folder and the file in the same line and I'm wondering if there's a way to seperate them.

    Code:
    private void CompressFile(string DirectoryPath)
    {
        DirectoryInfo di = new DirectoryInfo(DirectoryPath);
        FileInfo fi = new FileInfo(DirectoryPath);
    
        using (FileStream inFile = fi.OpenRead())
        {
            using (FileStream outFile = File.Create(fi.Directory + "\\(" + currTime.ToShortDateString() + ")RSDB.accdb.gz"))
            {
                using (GZipStream Compress = new GZipStream(outFile, CompressionMode.Compress))
                {
                    inFile.CopyTo(Compress);
                }
            } 
        }  
    }
    This is the line that sets the name:
    Code:
    using (FileStream outFile = File.Create(fi.Directory + "\\(" + currTime.ToShortDateString() + ")RSDB.accdb.gz"))
    Taking away the first extension leaves the file without any extension at all.
Working...