cancel
Showing results for 
Search instead for 
Did you mean: 

Delete the folder through webdynro

Former Member
0 Kudos

hi expert

I have simple query .

I have created one simple application in that i have created the simple folder in j2ee server. i want to delete this folder and content of this folder throught dynpro.how to do ?.

any body tell me the code of this ?

reply

thanks & Regards

vijay yewale

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this code

File f=new File(<YourFoldr Name>);

if(f.isDirectory())

f.delete();

Regards

LakshmiNarayana

Former Member
0 Kudos

thanks for the quick reply

Edited by: Vijay Yewale on Jun 20, 2008 10:22 AM

Answers (2)

Answers (2)

Former Member
0 Kudos

Vijay,

You can delete a directory using the following code


new File( Path).delete();

But if the folder is not empty; the code will not work; go through the following code to delete the child.


// using recursive function call, the child files/dirs will get deleted
public boolean deleteDirectory( File path) 
{
	if( path.exists() ) 
	{
      		File[] files = path.listFiles();
		 for(int i=0; i<files.length; i++) 
		{
		        if(files<i>.isDirectory()) 
		        {
			 deleteDirectory(files<i>);
		         }else{
			  files<i>.delete();
		         }
		}
}
    return( path.delete() );
}

Regards

Vinod V

Former Member
0 Kudos

Hi,

Make use of the delete method from the file

API

boolean delete()

Deletes the file or directory denoted by this abstract pathname.

http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html

Regards

Ayyapparaj