.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> VB.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to Delete Non-Empty Folder in Vb.net

Posted By: Santosh     Posted Date: February 03, 2010    Points:2   Category :VB.Net

can any body plz tell me how delete a Non-Empty Folder in vb.net.


Author: Akhil Raj       [Moderator]      
Posted Date: February 03, 2010     Points: 5   

try the following

If System.IO.Directory.exists(PATH) then _
System.io.directory.delete(PATH, true)

Please refer : http://msdn.microsoft.com/en-in/library/system.io.directory.delete(en-us,VS.80).aspx

Author: Santosh             
Posted Date: February 03, 2010     Points: 5   

hi akhil

this code will work for empty directory

but i need to delete non-empty folder.

Ex:MainFolder-->subFolder--->sub-sub folder--->some file

here i need to delete MailFolder


Author: Lalij Mer             
Posted Date: February 04, 2010     Points: 5   

show here discus


Please Check my answer if you help....
Thank You...

Author: Akhil Raj       [Moderator]      
Posted Date: February 04, 2010     Points: 5   

hi santhosh...

Directory.Delete("folderpath", true);

surly thi will delete the the 'folderpath' and all its sub contents. I tried. The second parameter boolean indicate whether delete all the subdirectories and coinetnts..

Anyway if not work check whther any hidden files or something like that attribute set files in the folder

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend