Thursday 17 April 2014

Move and Delete files using PeopleCode

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();

No comments:

Post a Comment