Войти или зарегистрироваться

Помогите Как удалить папку с помощью java6 ?

Так я сделал метод таким
Java:
public void deleteDirectory(File file) {
            if(!file.exists()) return;
            if(file.isDirectory()) {
                for(File f : file.listFiles())
 
                    f.delete();
                file.delete();
 
            }else{
                file.delete();
            }
 
        }
Метод getMcDir немного неправильный! т.к. удаление папки модс идет в папке AppData!:fp::why::fu:
Папка модс удаляеться исправно, но в папке AppData!
а в чём проблема? дописать небольшой код?
 
полный код в студию и желательно его под спойлер )
 
Java:
protected void UnZip() throws PrivilegedActionException
  {
    deleteDirectory(new File(getMcDir()+File.separator+"mods"));
    String szZipFilePath;
    String szExtractPath;
    String path = (String)AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
        public Object run() throws Exception {
          return Util.getWorkingDirectory() + File.separator;
        }
      });
    int i;
 
    szZipFilePath = path + "bin" + File.separator + "client.zip";
     
    File f = new File(szZipFilePath);
    if(!f.exists())
    {
      System.out.println(
    "\nNot found: " + szZipFilePath);
      //System.exit(0);
    }
     
    if(f.isDirectory())
    {
      System.out.println(
    "\nNot file: " + szZipFilePath);
      //System.exit(0);
    }
   
    System.out.println(
      "Enter path to extract files: ");
    szExtractPath = path;
   
    File f1 = new File(szExtractPath);
    if(!f1.exists())
    {
      System.out.println(
    "\nNot found: " + szExtractPath);
      //System.exit(0);
    }
     
    if(!f1.isDirectory())
    {
      System.out.println(
    "\nNot directory: " + szExtractPath);
      //System.exit(0);
    }
   
    ZipFile zf;
    Vector zipEntries = new Vector();
     
    try
    { 
      zf = new ZipFile(szZipFilePath);   
      Enumeration en = zf.entries();
     
      while(en.hasMoreElements())
      {
        zipEntries.addElement(
      (ZipEntry)en.nextElement());
      }
     
      for (i = 0; i < zipEntries.size(); i++)
      {
        ZipEntry ze =
      (ZipEntry)zipEntries.elementAt(i);
     
        extractFromZip(szZipFilePath, szExtractPath,
      ze.getName(), zf, ze);
      }
     
      zf.close();
      f.delete();
      System.out.println("Done!");
    }
    catch(Exception ex)
    {
      System.out.println(ex.toString());
    }
  }
 
 
 
     
 
private String getMcDir() {
    String s3;
   
    if (System.getProperty("os.name").startsWith("Windows"))
    {
        s3 = System.getenv("APPDATA");
    }
    else
    {
        s3 = System.getProperty("user.home");
    }
   
    return s3;
   
  }
 
public void deleteDirectory(File file) {
            if(!file.exists()) return;
            if(file.isDirectory()) {
                for(File f : file.listFiles())
 
                    f.delete();
                file.delete();
 
            }else{
                file.delete();
            }
 
        }
 
Java:
deleteDirectory(new File(getMcDir()+File.separator+"mods"));
замени на
Java:
deleteDirectory(new File(getMcDir()+ "\\.tvoi ololo proect\\mods"));
 
Назад
Верх