Question
2
Replies
1182
Views
Posted: March 13, 2018
Last activity: March 14, 2018
Create Folder at Local Directory
Hi, I'm have a requirement to make a web service (or anything like that). The main point is: 1. Create folder based on date and time, on local machine (not the server) 2. Inside the folder will have a txt file Can anyone suggest how to achieve this requirement, thanks :D (Currently on Pega 7.2.2)
Hi,
Pega doesn't provide any OOTB activity to achieve this. You will have to use Java here. You can create activity in Pega and put your java code there.
This will create a new folder with current timestamp:
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("hh mm ss");
String time = dateFormat.format(now);
File dir = new File(time);
dir.mkdir();
But keep in mind, while using JAVA in a Pega activity, you will have to fully qualify all classes. If you are not aware of it then you can check the OOTB activities and the Java steps written in them.
However as you have mentioned, you want to create the file on the local machine. For this, you will have to first set up a communication protocol between the server and the local machine. This might help you:
https://stackoverflow.com/questions/36805779/how-to-create-a-directory-on-a-server-machine-using-java-socket-of-a-client-mach