473,809 Members | 2,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Respons e;

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

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

GZipStream gzStream = new GZipStream(Resp onse.OutputStre am,
CompressionMode .Compress);

StreamWriter sw = new StreamWriter(gz Stream);

DataTable dt = Session["MyDataTabl e"];

if (dt != null)

{

int iColCount = dt.Columns.Coun t;

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

{

sw.Write(dt.Col umns[i]);

if (i < iColCount - 1)

{

sw.Write(",");

}

}

sw.Write(sw.New Line);

// Now write all the rows.

foreach (DataRow dr in dt.Rows)

{

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

{

if (!Convert.IsDBN ull(dr[i]))

{

sw.Write(dr[i].ToString().Tri m());

}

if (i < iColCount - 1)

{

sw.Write(",");

}

}

sw.Write(sw.New Line);

}

sw.Close();

Response.Conten tType = "applicatio n/x-Gzip";

Response.AddHea der("content-disposition", "attachment ; filename=" +
"compressed_fil e.gz");
Response.End();

}

}

S
Nov 9 '07 #1
4 1004

"Smith" <Sm***@pricatee mail.comwrote in message
news:eN******** ******@TK2MSFTN GP04.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***@pricatee mail.comwrote in message
news:O4******** ******@TK2MSFTN GP02.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
1591
by: Tom Gugger | last post by:
OMNI GROUP tgugger@buckeye-express.com 419-380-8853 BEA MIDDLEWARE EXPERT/ CONTRACT TO PERM/ PA
7
2344
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 - 1) ) when I look at the value of FM_ITEMS in my debug log it is 32.
15
1506
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 queries, they choke. For example I have a table that looks like this: PK_ID - primary key PARENT_ID - a FK to another row in the same table This essentially is a tree structure. I will ask interviewees to write
9
1139
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 program to use a .lib file in visualstudio.net. The example gives 2 files a exmple1.h file and an example1.lib file but I'm not sure how to use them. Many thanks,
4
2161
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 say i have a column in database that looks like this. PageID (int) Webcontrol (varchar) 1 MyNameSpace.WebControls.Control1
4
2069
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 authentication and not "server authentification" The code i wrote is quite straight forward. (See listing below) With server authentication, the server's application will contain a certificate created specifically for that server. The client...
3
4840
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
1389
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? Please excuse my lengthy message. +++ Web Form Structure +++ TextChanged event wired up.
0
1532
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 data that would work well (very well in fact) defined as XML documents and I want to enrich that data with additional User defined information (child and/or attribute) using an XML application. Document specifics 1. Document size 150k - 300k...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7661
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.