Issue with ZipOutputStream class in my .net application.

V

VijayV

Hi all,

I am working on a webapplication and trying to implement a logic of
downloading a .zip file when user clicks on a particular button.
This .zip file should be generated dynamically.

For this, I am using ZipOutputStream class. I am passing my string
(which should be converted as a .zip file) and outputstream. Please
see the below code.

System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();
byte[] buffer = encoder.GetBytes(toBeZippedString);

ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);

zipOutputStream.SetLevel(6); // 0 - store only to 9 - means best
compression

ZipEntry entry = new ZipEntry(GetFileName() + "." +
paymentFileType.ToLower().Trim());

entry.DateTime = DateTime.Now;
ICSharpCode.SharpZipLib.Checksums.Crc32 crc = new
ICSharpCode.SharpZipLib.Checksums.Crc32();

entry.Size = buffer.Length;

crc.Reset();
crc.Update(buffer);
entry.Crc = crc.Value;

zipOutputStream.PutNextEntry(entry);
zipOutputStream.Write(buffer, 0, buffer.Length);
zipOutputStream.Finish();
zipOutputStream.Close();


After executing this logic, user should get a popup window with
the .zip file from server with OPEN, SAVE, Cancel options.

This entire logic is working from my development PC. But, where as
when I deploy this at production server, I am getting an unhandled
exception (Whic is recorded at event log) like below

User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

Can anybody help me why this is occuring and what is the fix for this?

Thanks in advance and will be looking for the solution of this.

Thanks
VijayV
 
A

Arne Vajhøj

VijayV said:
I am working on a webapplication and trying to implement a logic of
downloading a .zip file when user clicks on a particular button.
This .zip file should be generated dynamically.

For this, I am using ZipOutputStream class. I am passing my string
(which should be converted as a .zip file) and outputstream. Please
see the below code.

System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();
byte[] buffer = encoder.GetBytes(toBeZippedString);

ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);

zipOutputStream.SetLevel(6); // 0 - store only to 9 - means best
compression

ZipEntry entry = new ZipEntry(GetFileName() + "." +
paymentFileType.ToLower().Trim());

entry.DateTime = DateTime.Now;
ICSharpCode.SharpZipLib.Checksums.Crc32 crc = new
ICSharpCode.SharpZipLib.Checksums.Crc32();

entry.Size = buffer.Length;

crc.Reset();
crc.Update(buffer);
entry.Crc = crc.Value;

zipOutputStream.PutNextEntry(entry);
zipOutputStream.Write(buffer, 0, buffer.Length);
zipOutputStream.Finish();
zipOutputStream.Close();


After executing this logic, user should get a popup window with
the .zip file from server with OPEN, SAVE, Cancel options.

This entire logic is working from my development PC. But, where as
when I deploy this at production server, I am getting an unhandled
exception (Whic is recorded at event log) like below

User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

Can anybody help me why this is occuring and what is the fix for this?

Why are you asking a .NET question in a Java group ?

The problem is obviously related to the account the server
is running under and its privileges (probably to the file
systems).

So you really need to provide more info to someone knowledgeable
about Windows (and this forum is not the best forum for that).

Arne
 
R

Roedy Green

User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

partition the problem. For now, place the a pre-computed zip file on
the server instead of generating it. See if your client can get it. I
suspect the problem is the user does not have authorisation to read
that directory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top