Move and Delete files using PeopleCode

1.1K 0 0
                                        

Move and Delete files using PeopleCode

We can use the below java object and code to move or deleting files from some location.

Moving file:

Local JavaObject &source = CreateJavaObject("java.io.File", "/source/file.txt");

Local JavaObject &target = CreateJavaObject("java.io.File", "/target/file.txt");

&source.renameTo(&target);

Deleting file:

Local JavaObject &DelLoc = CreateJavaObject("java.io.File", "/source/file.txt");

&DelLoc.delete();

Alternate code for deleting file:

&tmpfile = GetFile(“c:\temp\file.txt”, “W”, “A”, %FilePath_Absolute);

&tmpfile.Delete();

PeopleCodeWhere stories live. Discover now