c++ list遍历_Creo二次开发 文件循环遍历

文件遍历

    在实际业务中,Creo对文件操作时需要对制定的文件夹中的文件进行循环遍历,查找到符合要求的文件,以便进行操作

ProPath *file_list, *dir_list; //文件名和路径名称保存指针

ProName w_nm; //路径

ProStringToWstring(w_nm, (char*)("C:\\PTC\\Creo 2.0\\Common Files\\M130\\formats"));

ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&file_list);//分配数组

ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&dir_list); //分配数组

ProFilesList(w_nm, _T("*.frm"), PRO_FILE_LIST_ALL,  &file_list, &dir_list);//对路径下的frm格式文件进行过滤

CString str ;int count = 0 ;

ProArraySizeGet((ProArray*)file_list,&count);

str.Format(_T("一共有%d的文件"),count);

for (int i = 0;i

{

AfxMessageBox(file_list[i]);

               //针对查找符合要求的对象进行业务操作

}

31e7c5e983b5714def0125aab80c0a70.png

ProFilesList

ProError ProFilesList ( 

 ProPath directory_path  

 /* (In) 

 The directory in which to look for the files to be listed. If this is NULL, the files from the current directory will be listed. 

 */ 

 ProLine filter  

 /* (In) 

 The user-supplied filter string for file extensions. Each filter must be separated by a comma. For example, "*.prt,*.txt" (converted to a wide-character string). Each individual element in the filter must be less than PRO_NAME_SIZE characters. 

 */ 

 ProFileListOpt listing_option  

 /* (In) 

 Specifies whether all versions or only the latest versions are being requested, and whether or not the list should be sorted alphabetically. Note: Passing any of _INST options in Wildfire 4.0 M100 and earlier will have the same effect as passing PRO_FILE_LIST_LATEST. 

 */ 

 ProPath** p_file_name_array  

 /* (Out) 

 The array of files found. You must preallocate this array using ProArrayAlloc(); if you reuse the array, new elements will be appended to the existing elements unless you reset the array size to 0 with ProArraySizeSet. 

 */ 

 ProPath** p_subdir_name_array  

 /* (Out) 

 The array of all subdirectories found, regardless of whether they match the filter. You must preallocate this array using ProArrayAlloc(); if you reuse the array, new elements will be appended to the existing elements unless you reset the array size to 0 with ProArraySizeSet. 

 */ 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值