Save Function not quite right

Hi!
i’m trying to have a save function that allows you to name the file and choose where you would like your save to go.

So far with the code I have, its allows you to save and make/choose a folder but then places it onto the desktop with the name of the folder added onto the files name.

Have a look with the code below, any help would be great.Thanks!

void setup(){
  size(1080,720);
  background(255);
}
  
void draw(){
  ellipse(100,100,100,100);
  strokeWeight (50);
}
  
void keyPressed()
{
  if (key == 'r') 
  {
    setup();
  }
  if (key ==' ')
  {
    selectFolder("select a folder to process", "folderSelected");
  }
}

void folderSelected (File selection)
{
  if (selection == null)
  {
    return;
  } 
  else
  {
    String dir2 = selection.getPath();
    save(dir2+"Painting#.jpg");
  }
}
1 Like

Try println dir2

What do you get?

Where about do you mean?

like:

   String dir2 = selection.getPath();
    println(dir2+"Painting#.jpg");

Yes for example- either dir2 alone or with add

Maybe you have to insert


+ "//" +

before filename ?

2 Likes
+ "//" +

That worked!
Thank you so much

1 Like