Home All Groups Group Topic Archive Search About
Author
6 Sep 2006 12:17 AM
BobRoyAce
I am using Visual Studio .NET 2005 to create a Windows Forms
application. I know that I can use My.Computer.FileSystem.DeleteFile to
delete a file. How do I delete an empty folder/directory though? How
could I delete a folder that wasn't empty?

Author
6 Sep 2006 1:00 AM
Herfried K. Wagner [MVP]
"BobRoyAce" <b***@omegasoftwareinc.com> schrieb:
>I am using Visual Studio .NET 2005 to create a Windows Forms
> application. I know that I can use My.Computer.FileSystem.DeleteFile to
> delete a file. How do I delete an empty folder/directory though? How
> could I delete a folder that wasn't empty?

'My.Computer.FileSystem.DeleteDirectory'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
6 Sep 2006 3:12 AM
BobRoyAce
Yea, that would make sense...thanks. I looked for DeleteFolder...never
even looked for DeleteDirectory!

Herfried K. Wagner [MVP] wrote:
Show quoteHide quote
> "BobRoyAce" <b***@omegasoftwareinc.com> schrieb:
> >I am using Visual Studio .NET 2005 to create a Windows Forms
> > application. I know that I can use My.Computer.FileSystem.DeleteFile to
> > delete a file. How do I delete an empty folder/directory though? How
> > could I delete a folder that wasn't empty?
>
> 'My.Computer.FileSystem.DeleteDirectory'.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
6 Sep 2006 1:59 AM
Chris
Hi BobRoyAce,

I tried

Try
    System.IO.Directory.Delete("C:\test", True)
Catch ex As Exception
    MsgBox(ex.message.tostring)
End Try


Have a look at http://msdn2.microsoft.com/en-us/library/fxeahc5f.aspx for
more information

Best regards,

Chris

Show quoteHide quote
"BobRoyAce" <b***@omegasoftwareinc.com> wrote in message
news:1157501838.537881.86290@h48g2000cwc.googlegroups.com...
>I am using Visual Studio .NET 2005 to create a Windows Forms
> application. I know that I can use My.Computer.FileSystem.DeleteFile to
> delete a file. How do I delete an empty folder/directory though? How
> could I delete a folder that wasn't empty?
>