# Visual Basic > Visual Basic .NET > VS 2022 read contents of a gzip file

## Amerigoware

I am trying to read and edit a file within a gzip file. I can do this with .zip files, but I get an error when trying to read the .gzip file.
Search results so far only talk about compressing or decompressing .gzip files.
If relative, the .gzip file (as per file properties) actually has a ".dat" extension. The file I need to edit within it doesn't have any extension.



```
        Using archive As ZipArchive = Compression.ZipFile.Open(Path.Combine(SelectedWorld, "level.dat"), ZipArchiveMode.Update)
            Dim entry As ZipArchiveEntry = archive.GetEntry("level")
            Dim s As String = ""
            Using sr As New StreamReader(entry.Open())
                s = sr.ReadToEnd()
            End Using
            Dim M As Match = Regex.Match(s, "LevelName")
            If M.Success Then
                MsgBox(M.Value)
            'edit word after "LevelName"  <<I'm going to need help with this too.
            End If
        End Using
```




> System.IO.InvalidDataException: 'End of Central Directory record could not be found.'


Trying the following doesn't seem to have the right stuff to read/modify a file.


```
Using archive As IO.Compression.GZipStream = IO.Compression.GZipStream
```

----------


## Amerigoware

What I needed was a tool for dealing with NBT files.


```
Imports Cyotek.Data.Nbt

    Private Sub RenameToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RenameToolStripMenuItem.Click
        NewName = InputBox("Enter New Name")
        Dim MyFile As String = Path.Combine(SelectedWorld, "level.dat")
        Dim document As NbtDocument = NbtDocument.LoadDocument(MyFile)
        Dim root As TagCompound = document.DocumentRoot
        root.Name = "Data"
        Dim TC As TagCompound = root.GetCompound("Data")
        Dim MyTag As Tag = TC.GetTag("LevelName")
        MyTag.SetValue(NewName)
        document.Save(MyFile)
```

----------


## wqweto

There is no FS (file system) within gzip file like within zip archive so there is no original filename nor attribs or anything metadata. Gzip stream is a compressed byte-array and its up to decompressor to designate output filename which is usually constructed from original filename with .gz suffix stripped. Finding anything named .dat inside the .gz file is pure fiction i.e. this is a madeup filename/metadata by the decompressing classes.

This is the reason why you get .tar.gz files from Linux world so that .tar file has a whole FS albeit uncompressed while the .gz compresses this single .tar file.

----------

