Need C# Code to Compress KMZ file

Status
Not open for further replies.

pras_123

New member
Joined
Jan 20, 2012
Messages
2
Programming Experience
3-5
Hi All,


I Need C# Code to Compress KMZ file.


Below is a piece of code which is used to save Datagrid data to KMZ.
But I need code to compress KMZ .
Thanks for your help in advance.







/// <summary>
/// This function brings up a SaveFileDialog to offer the user a choice in naming
/// the file that is to be saved.
/// </summary>
private void SaveFileAsKMZ()
{
try
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.OverwritePrompt = false;
sfd.Filter = "Subdivision documents (*.kmz)|*.kmz";
sfd.Title = "Save Subdivision File As kmz";
sfd.InitialDirectory = DefaultSubdivDirectory;


SaveDefaultDirectoryLocation( sfd.FileName );
DialogResult dr = sfd.ShowDialog();
if( dr == DialogResult.OK )
{
if( File.Exists( sfd.FileName ) )
{
dr = MessageBox.Show(
"The file already exists.\n" +
"Overwrite or not?",
"File Exists!",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Asterisk );
}
if( dr == DialogResult.OK )
{
TrackTopologyFile topo = TopoFile;
KMZWriter writer = new KMZWriter( topo );
writer.DefaultDirectory = DefaultSubdivDirectory;


string sFileName = sfd.FileName;


bool bOk = writer.SaveAsKMZAdvanced( sFileName );


if( bOk )
{


MessageBox.Show(
"The following file was saved: \n" + sFileName,
"Saved!",
MessageBoxButtons.OK,
MessageBoxIcon.Information );
}
else
{
MessageBox.Show(
"An error occurred!\n" +
"The following file was NOT saved: \n" + sFileName,
"ERROR!",
MessageBoxButtons.OK,
MessageBoxIcon.Error );
}
}
}
}
 
If you would like help with C# then you should post at a C# forum rather than one for VB.NET. Here is a link to our C# sister site:

C# Developer Forums

When you post there, please wrap your code snippets in formatting tags. You can use the appropriate button on the advanced editor or you can just type the
VB.NET:
 or, preferably, [xcode=c#] tags yourself.
 
Status
Not open for further replies.
Back
Top