Create Folder Automatically
Hi,
I'm having a requirement like this ,
1. Create folder into desirable directory with custom format
2. Then, create new txt file inside on the folder created on step 1
Is this possible?
Thanks for your kindness ..
Regards
-
Like (0)
-
Accepted Solution

Hi,
I observed in logs that the error -"The system cannot find the path specified" is coming up. So, now first I created a folder and then in the same folder, I created my desired file. I have verified the code at my end and it seems to create "Folder" and "File" as well. Just that first I will create a folder and then file.
Please see the attached code and let me know if this works at your end as well.
Regards,
Rachit

Hi,
You can write an activity. In this activity, write a java step. Use the below code in that step.
File myFile = new File("D://XYZ/myFile.txt");
try {
flag = myFile.createNewFile();
} catch (IOException ioe) {
olog.infoForced("Error while Creating File in Java" + ioe);
}
olog.infoForced("file" + myFile.getPath() + " created ");
}
This will automatically create a folder name XYZ and myfile.txt inside this folder.
Please let me know if this resolves your issue.
Regards,
Rachit

Hi Rachit thanks for your answer,
I'm already trying your code and it show error code like the attachments (picture number 1 until 3) that i'm already upload ..
And i'm already trying to modify your code and not having error (picture number 4) , but it can't create the folder and etc. Maybe another solution or somewhat like that?
Thanks.
Regards

I have modified the code and it is getting compiled successfully at my end. Please use below code.
boolean flag=false;
java.io.File myFile = new java.io.File("D://XYZ//myFile.txt");
try {
flag = myFile.createNewFile();
} catch (java.io.IOException ioe) {
oLog.infoForced("Error while Creating File in Java" + ioe);
}
oLog.infoForced("file" + myFile.getPath() + " created ");
Let me know if this resolves the issue.
Accepted Solution

Hi,
I observed in logs that the error -"The system cannot find the path specified" is coming up. So, now first I created a folder and then in the same folder, I created my desired file. I have verified the code at my end and it seems to create "Folder" and "File" as well. Just that first I will create a folder and then file.
Please see the attached code and let me know if this works at your end as well.
Regards,
Rachit

Hi Rachit ,
Thanks for your answer. Now i'm already trying your given code but still can't get the result like you do. I'm trying your code with java step on activity, and call the activity using run activity or refresh this section on a button.
Maybe you can share with me how the step you procure to get the result , Thanks.
Regards,
Revian

Hi,
Please check the parent directory permissions if you are using Linux OS, please grant 777 permissions and check once.

Hi SudhakarReddy,
Thanks for your response. Fyi, i'm using windows OS .. and trying on other directory except the system but still not created.
Regards

I used a run-Activity on a click-event inside a section and it is working perfectly for me. Please find the attached screenshots for reference. Please excuse the names used in screenshots. If it is not working for you, can you please check the PegaRULES log file and see if the java step fails there. Alternatively, you can have a look at RegaALERT logs and see if anything is generated there, though I am not sure if anything will come up there.

Hi Rachit,
Thanks for your time .. when i'm using tracer , it show good at java step and here the log file when running the activity (check attachments, thanks).

In the log file, it is clearly seen that the file/folder is created successfully. There are no exceptions regarding that. Then, in this scenario, I don't think there is an issue from PRPC side. Can you please check the privileges.

Hi Rachit,
yeah , it's created successfully based on the log file. But still not created on my directory (you can see the attachment).
You suggest me to check the privileges, on PEGA Access group privilleges or on my PC? Can you give some example of the privilleges you have so can make you create the folder? Thanks
Regards..

Where is your server located? I think it is working for me because I have a server on my local machine itself and use case I am running on my machine itself. So can try and create a folder/file in the server location.

Hi Rachit,
I'm already check about that issued, and it's (the folder) placed on the server side .. Thanks for your time and solving my case.
Regards,
Revian