Delete Multiple Files Using PeopleCode

本文介绍了一种使用PeopleCode从服务器上删除文件的方法。通过指定文件路径和名称,可以批量删除符合特定条件的文件。文章提供了代码示例,包括显示待删除文件路径和名称、查找文件、逐个删除文件及检查删除状态的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值