PC Review


Reply
Thread Tools Rate Thread

Delete file within a zip file

 
 
Kevin Beckham
Guest
Posts: n/a
 
      21st May 2009
With an existing zip file, how can I delete one of the zipped files ?

I can reference the file with something like
Set oApp = CreateObject("Shell.Application")
With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)

End With

but can't get the verb to use to be able to delete it.

I have tried using the code that accesses zip32.dll and unzip32.dll and,
while it will happily add and extract files from the zip file, it corrupts
the zip file when i try to delete one of its members.

Any help greatly appreciated
TIA
Kevin Beckham
 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      21st May 2009
the syntax is
DeleteFile {filename}


Option Explicit
Sub demo()
Dim sFilename As String
sFilename = "C:\test\somefile.zip"
DeleteFile sFilename
End Sub

"Kevin Beckham" <(E-Mail Removed)> wrote in message
news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
> With an existing zip file, how can I delete one of the zipped files ?
>
> I can reference the file with something like
> Set oApp = CreateObject("Shell.Application")
> With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
>
> End With
>
> but can't get the verb to use to be able to delete it.
>
> I have tried using the code that accesses zip32.dll and unzip32.dll and,
> while it will happily add and extract files from the zip file, it corrupts
> the zip file when i try to delete one of its members.
>
> Any help greatly appreciated
> TIA
> Kevin Beckham


 
Reply With Quote
 
Kevin Beckham
Guest
Posts: n/a
 
      22nd May 2009
Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
delete the entire zip file, not a specific file within it

I eventually tracked down what was needed

oApp.Namespace(FileNameZip).items.Item _
(sFileToBeRemoved).InvokeVerb "&Delete"

will come up with the message that you about to permanently delete the file
and do you want to proceed.

The possible verbs are
&Open
Cu&t
&Copy
&Delete
P&roperties
for a file within a zip file (folder). It is probable that the ampersand
could be left out of the verb name.

Kevin

"Patrick Molloy" wrote:

> the syntax is
> DeleteFile {filename}
>
>
> Option Explicit
> Sub demo()
> Dim sFilename As String
> sFilename = "C:\test\somefile.zip"
> DeleteFile sFilename
> End Sub
>
> "Kevin Beckham" <(E-Mail Removed)> wrote in message
> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
> > With an existing zip file, how can I delete one of the zipped files ?
> >
> > I can reference the file with something like
> > Set oApp = CreateObject("Shell.Application")
> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
> >
> > End With
> >
> > but can't get the verb to use to be able to delete it.
> >
> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
> > while it will happily add and extract files from the zip file, it corrupts
> > the zip file when i try to delete one of its members.
> >
> > Any help greatly appreciated
> > TIA
> > Kevin Beckham

>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      24th May 2009
You can also use this to move it to the Temp folder or other folder

Dim oApp As Object
Set oApp = CreateObject("Shell.Application")

oApp.Namespace(Environ("Temp") & "\").MoveHere _
oApp.Namespace("C:\Users\Ron\Documents\ron.zip").items.Item("TestCodeTables.txt")

After that use Kill to delete the file

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Kevin Beckham" <(E-Mail Removed)> wrote in message news:C312AF11-554E-4330-81BE-(E-Mail Removed)...
> Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
> delete the entire zip file, not a specific file within it
>
> I eventually tracked down what was needed
>
> oApp.Namespace(FileNameZip).items.Item _
> (sFileToBeRemoved).InvokeVerb "&Delete"
>
> will come up with the message that you about to permanently delete the file
> and do you want to proceed.
>
> The possible verbs are
> &Open
> Cu&t
> &Copy
> &Delete
> P&roperties
> for a file within a zip file (folder). It is probable that the ampersand
> could be left out of the verb name.
>
> Kevin
>
> "Patrick Molloy" wrote:
>
>> the syntax is
>> DeleteFile {filename}
>>
>>
>> Option Explicit
>> Sub demo()
>> Dim sFilename As String
>> sFilename = "C:\test\somefile.zip"
>> DeleteFile sFilename
>> End Sub
>>
>> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
>> > With an existing zip file, how can I delete one of the zipped files ?
>> >
>> > I can reference the file with something like
>> > Set oApp = CreateObject("Shell.Application")
>> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
>> >
>> > End With
>> >
>> > but can't get the verb to use to be able to delete it.
>> >
>> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
>> > while it will happily add and extract files from the zip file, it corrupts
>> > the zip file when i try to delete one of its members.
>> >
>> > Any help greatly appreciated
>> > TIA
>> > Kevin Beckham

>>


 
Reply With Quote
 
Kevin Beckham
Guest
Posts: n/a
 
      25th May 2009
Thanks Ron, but a zip file doesn't behave like a normal folder. When you move
a file from it, the file remains behind - i.e. equivalent to a copy process.

I did encounter other unusual behaviour
'this code failed
Set oFolder = oApp.Namespace(sZipFile)
'this code worked
Set oFolder = oApp.Namespace("" & sZipFile)

irrespective of whether sZipFile is passed ByVal or ByRef

Kevin

"Ron de Bruin" wrote:

> You can also use this to move it to the Temp folder or other folder
>
> Dim oApp As Object
> Set oApp = CreateObject("Shell.Application")
>
> oApp.Namespace(Environ("Temp") & "\").MoveHere _
> oApp.Namespace("C:\Users\Ron\Documents\ron.zip").items.Item("TestCodeTables.txt")
>
> After that use Kill to delete the file
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
>
>
> "Kevin Beckham" <(E-Mail Removed)> wrote in message news:C312AF11-554E-4330-81BE-(E-Mail Removed)...
> > Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
> > delete the entire zip file, not a specific file within it
> >
> > I eventually tracked down what was needed
> >
> > oApp.Namespace(FileNameZip).items.Item _
> > (sFileToBeRemoved).InvokeVerb "&Delete"
> >
> > will come up with the message that you about to permanently delete the file
> > and do you want to proceed.
> >
> > The possible verbs are
> > &Open
> > Cu&t
> > &Copy
> > &Delete
> > P&roperties
> > for a file within a zip file (folder). It is probable that the ampersand
> > could be left out of the verb name.
> >
> > Kevin
> >
> > "Patrick Molloy" wrote:
> >
> >> the syntax is
> >> DeleteFile {filename}
> >>
> >>
> >> Option Explicit
> >> Sub demo()
> >> Dim sFilename As String
> >> sFilename = "C:\test\somefile.zip"
> >> DeleteFile sFilename
> >> End Sub
> >>
> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
> >> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
> >> > With an existing zip file, how can I delete one of the zipped files ?
> >> >
> >> > I can reference the file with something like
> >> > Set oApp = CreateObject("Shell.Application")
> >> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
> >> >
> >> > End With
> >> >
> >> > but can't get the verb to use to be able to delete it.
> >> >
> >> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
> >> > while it will happily add and extract files from the zip file, it corrupts
> >> > the zip file when i try to delete one of its members.
> >> >
> >> > Any help greatly appreciated
> >> > TIA
> >> > Kevin Beckham
> >>

>
>

 
Reply With Quote
 
Kevin Beckham
Guest
Posts: n/a
 
      25th May 2009
I'm using XP - a series of posts on the subject of MoveHere suggested that
there is a problem with the XP implementation of the Shell object. In
addition, it appears to totally ignore the intOptions parameter.

"Kevin Beckham" wrote:

> Thanks Ron, but a zip file doesn't behave like a normal folder. When you move
> a file from it, the file remains behind - i.e. equivalent to a copy process.
>
> I did encounter other unusual behaviour
> 'this code failed
> Set oFolder = oApp.Namespace(sZipFile)
> 'this code worked
> Set oFolder = oApp.Namespace("" & sZipFile)
>
> irrespective of whether sZipFile is passed ByVal or ByRef
>
> Kevin
>
> "Ron de Bruin" wrote:
>
> > You can also use this to move it to the Temp folder or other folder
> >
> > Dim oApp As Object
> > Set oApp = CreateObject("Shell.Application")
> >
> > oApp.Namespace(Environ("Temp") & "\").MoveHere _
> > oApp.Namespace("C:\Users\Ron\Documents\ron.zip").items.Item("TestCodeTables.txt")
> >
> > After that use Kill to delete the file
> >
> > --
> >
> > Regards Ron de Bruin
> > http://www.rondebruin.nl/tips.htm
> >
> >
> >
> >
> > "Kevin Beckham" <(E-Mail Removed)> wrote in message news:C312AF11-554E-4330-81BE-(E-Mail Removed)...
> > > Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
> > > delete the entire zip file, not a specific file within it
> > >
> > > I eventually tracked down what was needed
> > >
> > > oApp.Namespace(FileNameZip).items.Item _
> > > (sFileToBeRemoved).InvokeVerb "&Delete"
> > >
> > > will come up with the message that you about to permanently delete the file
> > > and do you want to proceed.
> > >
> > > The possible verbs are
> > > &Open
> > > Cu&t
> > > &Copy
> > > &Delete
> > > P&roperties
> > > for a file within a zip file (folder). It is probable that the ampersand
> > > could be left out of the verb name.
> > >
> > > Kevin
> > >
> > > "Patrick Molloy" wrote:
> > >
> > >> the syntax is
> > >> DeleteFile {filename}
> > >>
> > >>
> > >> Option Explicit
> > >> Sub demo()
> > >> Dim sFilename As String
> > >> sFilename = "C:\test\somefile.zip"
> > >> DeleteFile sFilename
> > >> End Sub
> > >>
> > >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
> > >> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
> > >> > With an existing zip file, how can I delete one of the zipped files ?
> > >> >
> > >> > I can reference the file with something like
> > >> > Set oApp = CreateObject("Shell.Application")
> > >> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
> > >> >
> > >> > End With
> > >> >
> > >> > but can't get the verb to use to be able to delete it.
> > >> >
> > >> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
> > >> > while it will happily add and extract files from the zip file, it corrupts
> > >> > the zip file when i try to delete one of its members.
> > >> >
> > >> > Any help greatly appreciated
> > >> > TIA
> > >> > Kevin Beckham
> > >>

> >
> >

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      25th May 2009
Hi Kevin

The code sample I posted run ok on VPC with Win Xp

Is the code on this page working for you ?
http://www.rondebruin.nl/windowsxpzip.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Kevin Beckham" <(E-Mail Removed)> wrote in message news:6007D9AE-6BEB-48EB-8B9D-(E-Mail Removed)...
> Thanks Ron, but a zip file doesn't behave like a normal folder. When you move
> a file from it, the file remains behind - i.e. equivalent to a copy process.
>
> I did encounter other unusual behaviour
> 'this code failed
> Set oFolder = oApp.Namespace(sZipFile)
> 'this code worked
> Set oFolder = oApp.Namespace("" & sZipFile)
>
> irrespective of whether sZipFile is passed ByVal or ByRef
>
> Kevin
>
> "Ron de Bruin" wrote:
>
>> You can also use this to move it to the Temp folder or other folder
>>
>> Dim oApp As Object
>> Set oApp = CreateObject("Shell.Application")
>>
>> oApp.Namespace(Environ("Temp") & "\").MoveHere _
>> oApp.Namespace("C:\Users\Ron\Documents\ron.zip").items.Item("TestCodeTables.txt")
>>
>> After that use Kill to delete the file
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.nl/tips.htm
>>
>>
>>
>>
>> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>> news:C312AF11-554E-4330-81BE-(E-Mail Removed)...
>> > Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
>> > delete the entire zip file, not a specific file within it
>> >
>> > I eventually tracked down what was needed
>> >
>> > oApp.Namespace(FileNameZip).items.Item _
>> > (sFileToBeRemoved).InvokeVerb "&Delete"
>> >
>> > will come up with the message that you about to permanently delete the file
>> > and do you want to proceed.
>> >
>> > The possible verbs are
>> > &Open
>> > Cu&t
>> > &Copy
>> > &Delete
>> > P&roperties
>> > for a file within a zip file (folder). It is probable that the ampersand
>> > could be left out of the verb name.
>> >
>> > Kevin
>> >
>> > "Patrick Molloy" wrote:
>> >
>> >> the syntax is
>> >> DeleteFile {filename}
>> >>
>> >>
>> >> Option Explicit
>> >> Sub demo()
>> >> Dim sFilename As String
>> >> sFilename = "C:\test\somefile.zip"
>> >> DeleteFile sFilename
>> >> End Sub
>> >>
>> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>> >> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
>> >> > With an existing zip file, how can I delete one of the zipped files ?
>> >> >
>> >> > I can reference the file with something like
>> >> > Set oApp = CreateObject("Shell.Application")
>> >> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
>> >> >
>> >> > End With
>> >> >
>> >> > but can't get the verb to use to be able to delete it.
>> >> >
>> >> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
>> >> > while it will happily add and extract files from the zip file, it corrupts
>> >> > the zip file when i try to delete one of its members.
>> >> >
>> >> > Any help greatly appreciated
>> >> > TIA
>> >> > Kevin Beckham
>> >>

>>
>>


 
Reply With Quote
 
Kevin Beckham
Guest
Posts: n/a
 
      26th May 2009
Your code works fine until I change FileNameZip from Variant to String, then
it fails
i.e. change
Dim FName, vArr, FileNameZip
to
Dim FName, vArr, FileNameZip As String

Kevin

"Ron de Bruin" wrote:

> Hi Kevin
>
> The code sample I posted run ok on VPC with Win Xp
>
> Is the code on this page working for you ?
> http://www.rondebruin.nl/windowsxpzip.htm
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
>
>
> "Kevin Beckham" <(E-Mail Removed)> wrote in message news:6007D9AE-6BEB-48EB-8B9D-(E-Mail Removed)...
> > Thanks Ron, but a zip file doesn't behave like a normal folder. When you move
> > a file from it, the file remains behind - i.e. equivalent to a copy process.
> >
> > I did encounter other unusual behaviour
> > 'this code failed
> > Set oFolder = oApp.Namespace(sZipFile)
> > 'this code worked
> > Set oFolder = oApp.Namespace("" & sZipFile)
> >
> > irrespective of whether sZipFile is passed ByVal or ByRef
> >
> > Kevin
> >
> > "Ron de Bruin" wrote:
> >
> >> You can also use this to move it to the Temp folder or other folder
> >>
> >> Dim oApp As Object
> >> Set oApp = CreateObject("Shell.Application")
> >>
> >> oApp.Namespace(Environ("Temp") & "\").MoveHere _
> >> oApp.Namespace("C:\Users\Ron\Documents\ron.zip").items.Item("TestCodeTables.txt")
> >>
> >> After that use Kill to delete the file
> >>
> >> --
> >>
> >> Regards Ron de Bruin
> >> http://www.rondebruin.nl/tips.htm
> >>
> >>
> >>
> >>
> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
> >> news:C312AF11-554E-4330-81BE-(E-Mail Removed)...
> >> > Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
> >> > delete the entire zip file, not a specific file within it
> >> >
> >> > I eventually tracked down what was needed
> >> >
> >> > oApp.Namespace(FileNameZip).items.Item _
> >> > (sFileToBeRemoved).InvokeVerb "&Delete"
> >> >
> >> > will come up with the message that you about to permanently delete the file
> >> > and do you want to proceed.
> >> >
> >> > The possible verbs are
> >> > &Open
> >> > Cu&t
> >> > &Copy
> >> > &Delete
> >> > P&roperties
> >> > for a file within a zip file (folder). It is probable that the ampersand
> >> > could be left out of the verb name.
> >> >
> >> > Kevin
> >> >
> >> > "Patrick Molloy" wrote:
> >> >
> >> >> the syntax is
> >> >> DeleteFile {filename}
> >> >>
> >> >>
> >> >> Option Explicit
> >> >> Sub demo()
> >> >> Dim sFilename As String
> >> >> sFilename = "C:\test\somefile.zip"
> >> >> DeleteFile sFilename
> >> >> End Sub
> >> >>
> >> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
> >> >> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
> >> >> > With an existing zip file, how can I delete one of the zipped files ?
> >> >> >
> >> >> > I can reference the file with something like
> >> >> > Set oApp = CreateObject("Shell.Application")
> >> >> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
> >> >> >
> >> >> > End With
> >> >> >
> >> >> > but can't get the verb to use to be able to delete it.
> >> >> >
> >> >> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
> >> >> > while it will happily add and extract files from the zip file, it corrupts
> >> >> > the zip file when i try to delete one of its members.
> >> >> >
> >> >> > Any help greatly appreciated
> >> >> > TIA
> >> >> > Kevin Beckham
> >> >>
> >>
> >>

>
>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      26th May 2009
That's correct it must be a variant



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Kevin Beckham" <(E-Mail Removed)> wrote in message news:74B8F2C8-A329-4398-98A7-(E-Mail Removed)...
> Your code works fine until I change FileNameZip from Variant to String, then
> it fails
> i.e. change
> Dim FName, vArr, FileNameZip
> to
> Dim FName, vArr, FileNameZip As String
>
> Kevin
>
> "Ron de Bruin" wrote:
>
>> Hi Kevin
>>
>> The code sample I posted run ok on VPC with Win Xp
>>
>> Is the code on this page working for you ?
>> http://www.rondebruin.nl/windowsxpzip.htm
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.nl/tips.htm
>>
>>
>>
>>
>> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>> news:6007D9AE-6BEB-48EB-8B9D-(E-Mail Removed)...
>> > Thanks Ron, but a zip file doesn't behave like a normal folder. When you move
>> > a file from it, the file remains behind - i.e. equivalent to a copy process.
>> >
>> > I did encounter other unusual behaviour
>> > 'this code failed
>> > Set oFolder = oApp.Namespace(sZipFile)
>> > 'this code worked
>> > Set oFolder = oApp.Namespace("" & sZipFile)
>> >
>> > irrespective of whether sZipFile is passed ByVal or ByRef
>> >
>> > Kevin
>> >
>> > "Ron de Bruin" wrote:
>> >
>> >> You can also use this to move it to the Temp folder or other folder
>> >>
>> >> Dim oApp As Object
>> >> Set oApp = CreateObject("Shell.Application")
>> >>
>> >> oApp.Namespace(Environ("Temp") & "\").MoveHere _
>> >> oApp.Namespace("C:\Users\Ron\Documents\ron.zip").items.Item("TestCodeTables.txt")
>> >>
>> >> After that use Kill to delete the file
>> >>
>> >> --
>> >>
>> >> Regards Ron de Bruin
>> >> http://www.rondebruin.nl/tips.htm
>> >>
>> >>
>> >>
>> >>
>> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>> >> news:C312AF11-554E-4330-81BE-(E-Mail Removed)...
>> >> > Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
>> >> > delete the entire zip file, not a specific file within it
>> >> >
>> >> > I eventually tracked down what was needed
>> >> >
>> >> > oApp.Namespace(FileNameZip).items.Item _
>> >> > (sFileToBeRemoved).InvokeVerb "&Delete"
>> >> >
>> >> > will come up with the message that you about to permanently delete the file
>> >> > and do you want to proceed.
>> >> >
>> >> > The possible verbs are
>> >> > &Open
>> >> > Cu&t
>> >> > &Copy
>> >> > &Delete
>> >> > P&roperties
>> >> > for a file within a zip file (folder). It is probable that the ampersand
>> >> > could be left out of the verb name.
>> >> >
>> >> > Kevin
>> >> >
>> >> > "Patrick Molloy" wrote:
>> >> >
>> >> >> the syntax is
>> >> >> DeleteFile {filename}
>> >> >>
>> >> >>
>> >> >> Option Explicit
>> >> >> Sub demo()
>> >> >> Dim sFilename As String
>> >> >> sFilename = "C:\test\somefile.zip"
>> >> >> DeleteFile sFilename
>> >> >> End Sub
>> >> >>
>> >> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>> >> >> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
>> >> >> > With an existing zip file, how can I delete one of the zipped files ?
>> >> >> >
>> >> >> > I can reference the file with something like
>> >> >> > Set oApp = CreateObject("Shell.Application")
>> >> >> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
>> >> >> >
>> >> >> > End With
>> >> >> >
>> >> >> > but can't get the verb to use to be able to delete it.
>> >> >> >
>> >> >> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
>> >> >> > while it will happily add and extract files from the zip file, it corrupts
>> >> >> > the zip file when i try to delete one of its members.
>> >> >> >
>> >> >> > Any help greatly appreciated
>> >> >> > TIA
>> >> >> > Kevin Beckham
>> >> >>
>> >>
>> >>

>>
>>


 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      26th May 2009
I add a note on both pages now that you must use a variant

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Ron de Bruin" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> That's correct it must be a variant
>
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
>
>
> "Kevin Beckham" <(E-Mail Removed)> wrote in message
> news:74B8F2C8-A329-4398-98A7-(E-Mail Removed)...
>> Your code works fine until I change FileNameZip from Variant to String, then
>> it fails
>> i.e. change
>> Dim FName, vArr, FileNameZip
>> to
>> Dim FName, vArr, FileNameZip As String
>>
>> Kevin
>>
>> "Ron de Bruin" wrote:
>>
>>> Hi Kevin
>>>
>>> The code sample I posted run ok on VPC with Win Xp
>>>
>>> Is the code on this page working for you ?
>>> http://www.rondebruin.nl/windowsxpzip.htm
>>>
>>> --
>>>
>>> Regards Ron de Bruin
>>> http://www.rondebruin.nl/tips.htm
>>>
>>>
>>>
>>>
>>> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>>> news:6007D9AE-6BEB-48EB-8B9D-(E-Mail Removed)...
>>> > Thanks Ron, but a zip file doesn't behave like a normal folder. When you move
>>> > a file from it, the file remains behind - i.e. equivalent to a copy process.
>>> >
>>> > I did encounter other unusual behaviour
>>> > 'this code failed
>>> > Set oFolder = oApp.Namespace(sZipFile)
>>> > 'this code worked
>>> > Set oFolder = oApp.Namespace("" & sZipFile)
>>> >
>>> > irrespective of whether sZipFile is passed ByVal or ByRef
>>> >
>>> > Kevin
>>> >
>>> > "Ron de Bruin" wrote:
>>> >
>>> >> You can also use this to move it to the Temp folder or other folder
>>> >>
>>> >> Dim oApp As Object
>>> >> Set oApp = CreateObject("Shell.Application")
>>> >>
>>> >> oApp.Namespace(Environ("Temp") & "\").MoveHere _
>>> >> oApp.Namespace("C:\Users\Ron\Documents\ron.zip").items.Item("TestCodeTables.txt")
>>> >>
>>> >> After that use Kill to delete the file
>>> >>
>>> >> --
>>> >>
>>> >> Regards Ron de Bruin
>>> >> http://www.rondebruin.nl/tips.htm
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>>> >> news:C312AF11-554E-4330-81BE-(E-Mail Removed)...
>>> >> > Thanks Patrick, but DeleteFile is part of FileSystemObject - your code would
>>> >> > delete the entire zip file, not a specific file within it
>>> >> >
>>> >> > I eventually tracked down what was needed
>>> >> >
>>> >> > oApp.Namespace(FileNameZip).items.Item _
>>> >> > (sFileToBeRemoved).InvokeVerb "&Delete"
>>> >> >
>>> >> > will come up with the message that you about to permanently delete the file
>>> >> > and do you want to proceed.
>>> >> >
>>> >> > The possible verbs are
>>> >> > &Open
>>> >> > Cu&t
>>> >> > &Copy
>>> >> > &Delete
>>> >> > P&roperties
>>> >> > for a file within a zip file (folder). It is probable that the ampersand
>>> >> > could be left out of the verb name.
>>> >> >
>>> >> > Kevin
>>> >> >
>>> >> > "Patrick Molloy" wrote:
>>> >> >
>>> >> >> the syntax is
>>> >> >> DeleteFile {filename}
>>> >> >>
>>> >> >>
>>> >> >> Option Explicit
>>> >> >> Sub demo()
>>> >> >> Dim sFilename As String
>>> >> >> sFilename = "C:\test\somefile.zip"
>>> >> >> DeleteFile sFilename
>>> >> >> End Sub
>>> >> >>
>>> >> >> "Kevin Beckham" <(E-Mail Removed)> wrote in message
>>> >> >> news:972139F4-4968-4AB2-85AD-(E-Mail Removed)...
>>> >> >> > With an existing zip file, how can I delete one of the zipped files ?
>>> >> >> >
>>> >> >> > I can reference the file with something like
>>> >> >> > Set oApp = CreateObject("Shell.Application")
>>> >> >> > With oApp.Namespace(FileNameZip).Items.item(sFileToBeRemoved)
>>> >> >> >
>>> >> >> > End With
>>> >> >> >
>>> >> >> > but can't get the verb to use to be able to delete it.
>>> >> >> >
>>> >> >> > I have tried using the code that accesses zip32.dll and unzip32.dll and,
>>> >> >> > while it will happily add and extract files from the zip file, it corrupts
>>> >> >> > the zip file when i try to delete one of its members.
>>> >> >> >
>>> >> >> > Any help greatly appreciated
>>> >> >> > TIA
>>> >> >> > Kevin Beckham
>>> >> >>
>>> >>
>>> >>
>>>
>>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Macro to Open File, Delete Contents, Save New File Flintstone Microsoft Excel Misc 2 1st Feb 2010 11:25 PM
When trying to delete a font "Cannot move file: Cannot read from source file or disk. ldliebhart Windows XP Help 4 13th Sep 2009 10:45 PM
File.Move vs (File.Copy and File.Delete) Chris Microsoft VB .NET 1 9th May 2004 07:19 AM
ATTN: Robert B. Clark re: Delete file body, leave file name? Captain Infinity Windows XP General 8 1st Feb 2004 02:24 PM
error message -- cannot delete file: cannot read the source file or disk. EugeneN Microsoft Windows 2000 File System 0 10th Jul 2003 11:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 PM.