How to delete a zip file via asp.net code I am writing the following code on button click: Directory

Posted by Sp under ASP.NET on 12/7/2010 | Points: 10 | Views : 2452 | Status : [Member] | Replies : 2
How to delete a zip file via asp.net code
I am writing the following code on button click:
Directory.Delete("C:\\Documents and Settings\\hfhf\\My Documents\\My Pictures\\a.zip", true);
It says:
directory name is invalid




Responses

Posted by: T.saravanan on: 12/7/2010 [Member] [MVP] Silver | Points: 25
Posted by: Lalji_mer on: 12/7/2010 [Member] Bronze | Points: 25

Up
0
Down
hi,,
Try to below code sample
using System;

// This namespace contains the main class - ZipForge.
// Don't forget to add a reference to the ZipForge
// assembly to your project references
using ComponentAce.Compression.ZipForge;
// This namespace contains ArchiverException class
// required for error handling
using ComponentAce.Compression.Archiver;

namespace DeleteFile
{
class Program
{
static void Main(string[] args)
{
// Create an instance of the ZipForge class
ZipForge archiver = new ZipForge();
try
{
// Set the name of the archive file we want to create
archiver.FileName = @"c:\test.zip";
// open an existing ZIP file
archiver.OpenArchive(System.IO.FileMode.Open);
// delete a file from archive
archiver.DeleteFiles("file.txt");
archiver.CloseArchive();
}
catch (ArchiverException ae)
{
Console.WriteLine("Message: {0}\t Error code: {1}",
ae.Message, ae.ErrorCode);
// Wait for the key to be pressed
Console.ReadLine();
}
}
}
}


For reference link will good help you
http://www.componentace.com/delete-file-from-zip-in-c-sharp.htm

LP MER

Sp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response