473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Expert advice needed!

Hello,
My code below create a .CSV file and compress it with the new GZipStream
class.

My problem, is how to set the extension of the uncompressed file to .csv.
Users have to manually do this and it is not quite convenient. Any help will
be highly appreciated.

File: handler.ashx:
public void ProcessRequest(HttpContext context)

{

HttpResponse Response = context.Response;

HttpRequest Request = context.Request;
Response.Clear();

Response.Buffer = true;
//Using a new compression class of the framework

GZipStream gzStream = new GZipStream(Response.OutputStream,
CompressionMode.Compress);

StreamWriter sw = new StreamWriter(gzStream);

DataTable dt = Session["MyDataTable"];

if (dt != null)

{

int iColCount = dt.Columns.Count;

for (int i = 0; i < iColCount; i++)

{

sw.Write(dt.Columns[i]);

if (i < iColCount - 1)

{

sw.Write(",");

}

}

sw.Write(sw.NewLine);

// Now write all the rows.

foreach (DataRow dr in dt.Rows)

{

for (int i = 0; i < iColCount; i++)

{

if (!Convert.IsDBNull(dr[i]))

{

sw.Write(dr[i].ToString().Trim());

}

if (i < iColCount - 1)

{

sw.Write(",");

}

}

sw.Write(sw.NewLine);

}

sw.Close();

Response.ContentType = "application/x-Gzip";

Response.AddHeader("content-disposition", "attachment; filename=" +
"compressed_file.gz");
Response.End();

}

}

S
Nov 9 '07 #1
4 993

"Smith" <Sm***@pricateemail.comwrote in message
news:eN**************@TK2MSFTNGP04.phx.gbl...
Hello,
My code below create a .CSV file and compress it with the new GZipStream
class.

My problem, is how to set the extension of the uncompressed file to .csv.
Users have to manually do this and it is not quite convenient. Any help
will be highly appreciated.

here's a discussion of your issue:

http://msdn.microsoft.com/msdnmag/is...10/NETMatters/


Nov 9 '07 #2
>
http://msdn.microsoft.com/msdnmag/is...10/NETMatters/
Hello Barrie Wilson,

Thank you for the link. This seems to be the only online resource i have
come accross that addresses this matter.

Cheers
S
Nov 9 '07 #3
>
here's a discussion of your issue:

http://msdn.microsoft.com/msdnmag/is...10/NETMatters/
The more i got into this, the more i see that it does not solve my problem
anyway. This solution seems only to apply to file system files. I do not
have a file on disk. I have my data in memory in a data table.

Any furthere thoughts?

Thanks
Smith
Nov 9 '07 #4
"Smith" <Sm***@pricateemail.comwrote in message
news:O4**************@TK2MSFTNGP02.phx.gbl...
The more i got into this, the more i see that it does not solve my problem
anyway. This solution seems only to apply to file system files. I do not
have a file on disk. I have my data in memory in a data table.
I use the Chilkat Zip component for this type of thing.

It has a method specifically designed to solve your particular problem:
http://www.chilkatsoft.com/refdoc/cs...html#method033

Incidentally, it also has full GZip support, though you don't need that in
this instance...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Gugger | last post by:
OMNI GROUP tgugger@buckeye-express.com 419-380-8853 BEA MIDDLEWARE EXPERT/ CONTRACT TO PERM/ PA
7
by: John Smith | last post by:
Hi All, Sorry if I am calling expert's advice on such a simple thing. I am reading a c++ code but do not understand what this means? #define DM_ITEMS 6 #define FM_ITEMS ( 1 << (DM_ITEMS -...
15
by: Don Vaillancourt | last post by:
I do a lot of hiring for my company and a lot of the people I interview say that they are experts at SQL queries, but when I give them something simple just beyond the typical SELECT type of...
9
by: hoggmeister | last post by:
Hey Folks, I'm new to C/C++ programming and have just started looking at some books myself with a view to starting a course next year. I was wondering if anyone could tell me how to tell a...
4
by: jesper_lofgren | last post by:
Hi there, I have some webcontrols that i want to add dynamically on a page. I have stored the path / namespace in database (ex MyNameSpace.WebControls.Control1) to the class/webcontrol. Lets...
4
by: jens Jensen | last post by:
Hello, I was given the task to build a .Net client that will talk to IBM integration server via HTTP post. The idea is that each http packet exchange should be authenticated via X09 "client...
3
by: apattin | last post by:
Hi all, I need some expert advice on a ROLLUP fine point. summary_table table has 4 columns: file_id primary_site morphology primary
3
by: Tony | last post by:
I have a WebApp with 3 text boxes and 1 button, as described below. Can someone please explain why the bad scenarios are occurring and better still if they can be prevented or worked-around?...
0
by: onegative | last post by:
G'day Y'all, I was hoping to get some expert feedback on a proposal I am considering regarding a new internal application to help fill some gaps in our IT department. I have some configuration...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.