Delete Multiple Files Using PeopleCode

Deleting files sitting on a server using PeopleCode is one thing I'm sure you will be doing sometime during your PeopleSoft career. The code below should help you out and get you started!

/*The path to the files you need to delete*/
&oldFilesPath = "/my_directory/my_folder";
/*Notice the "*" at the end of the file name. This means any file that starts with "file_name" will be deleted*/
&oldFiles = "file_name" | "*";
&PathAndName = &oldFilesPath | &oldFiles;
/*Display file path and name to be deleted */
MessageBox(0, "", 0, 0, "Delete file: " | &PathAndName);
&oldFileNames = FindFiles(&PathAndName, %FilePath_Absolute);
/*Loop through files found and delete one by one */
While &oldFileNames.Len > 0/* Delete files one at a time */
&deleteFile = "http://www.cnblogs.com/../.." | &oldFileNames.Shift();
/*Display file path and name deleted */
&retcode = DeleteAttachment(URL, &deleteFile);
MessageBox(0, "", 0, 0, "Deleted file: " | &deleteFile);
/*Check delete status*/
If (&retcode = %Attachment_Success) Then

MessageBox(0, "File Attachment Status", 0, 0, "DeleteAttachment succeeded");
End-If;

If (&retcode = %Attachment_Failed) Then

MessageBox(0, "File Attachment Status", 0, 0, "DeleteAttachment failed");

End-If;

If (&retcode = %Attachment_Cancelled) Then

MessageBox(0, "File Attachment Status", 0, 0, "DeleteAttachment cancelled");

End-If;

If (&retcode = %Attachment_FileTransferFailed) Then

MessageBox(0, "File Attachment Status", 0, 0, "DeleteAttachment failed: File Transfer did not succeed");

End-If;
End-While;

转载于:https://www.cnblogs.com/GoDevil/archive/2008/08/21/1273326.html

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值