dict=[] //it's not a dict, it's a list, the dictionary is dict={}
elem=[1,2,3]
dict.append(elem)
можно получить доступ к единственному элементу таким образом:
print dict[0] // 0 is the index
вывод будет:
[1, 2, 3]
Моя первая мысль, что вы не закрыли csStream
. Если вы используете с помощью
, это произойдет автоматически. Поскольку gzip буферизует данные, некоторые из них могут отсутствовать.
Во-вторых; не увеличивать смещение
; это смещение в буфере (не в потоке). Оставьте 0:
using (Stream fs = File.OpenRead("gj.txt"))
using (Stream fd = File.Create("gj.zip"))
using (Stream csStream = new GZipStream(fd, CompressionMode.Compress))
{
byte[] buffer = new byte[1024];
int nRead;
while ((nRead = fs.Read(buffer, 0, buffer.Length))> 0)
{
csStream.Write(buffer, 0, nRead);
}
}
using (Stream fd = File.Create("gj.new.txt"))
using (Stream fs = File.OpenRead("gj.zip"))
using (Stream csStream = new GZipStream(fs, CompressionMode.Decompress))
{
byte[] buffer = new byte[1024];
int nRead;
while ((nRead = csStream.Read(buffer, 0, buffer.Length)) > 0)
{
fd.Write(buffer, 0, nRead);
}
}