AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 03.10.2012, 18:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
ax-erp: How to traverse a directory in Axapta
Источник: http://microsoft-dynamics-ax-erp.blo...in-axapta.html
==============


This example list all files in a directory including sub-directories. Handy when you need to do something with a number of files stored in a structure of folders. Here we lists all the text files it can find, you only need to alter the FO_ProcessFile() method for your needs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
static void FO_ListTreeExample(Args _args)
{
void FO_ProcessFile(FilePath _path, FileName _name)
{
;
info( strfmt(" %1 / %2 ", _path, _name) );
}

void FO_ProcessFolder(FilePath _path, FileName _mask)
#WinApi
{
FileName fileName;
container fileInfo;
int fileHandle, attrs;
;

// traverse all sub-directories
fileInfo = WinApi::findFirstFile(_path + "\\*.*");
fileHandle = conpeek(fileInfo,1);
fileName = conpeek(fileInfo,2);
while(fileName != '')
{
if(fileName != '..' && fileName != '.')
{
attrs = WinApi::getFileAttributes(
_path + "\\"+fileName);
if(attrs & #FILE_ATTRIBUTE_DIRECTORY)
FO_ProcessFolder(_path+'\\'+fileName,
_mask);
}
fileName = WinApi::findNextFile(fileHandle);
}

// traverse all files on this level
fileInfo = WinApi::findFirstFile(_path+"\\"+_mask);
fileHandle = conpeek(fileInfo,1);
fileName = conpeek(fileInfo,2);
while(fileName != '')
{
if(fileName != '..' && fileName != '.')
{
attrs = WinApi::getFileAttributes(
_path + "\\"+fileName);
if( !(attrs & #FILE_ATTRIBUTE_DIRECTORY) )
FO_ProcessFile(_path, fileName);
}
fileName = WinApi::findNextFile(fileHandle);
}
};

FO_ProcessFolder("c:\\Temp", "*.txt");
}





Источник: http://microsoft-dynamics-ax-erp.blo...in-axapta.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
ax-erp: How to Enable/Disable fields in a dialog Blog bot DAX Blogs 0 19.09.2012 20:11
ax-erp: How to build form by code Dynamics AX 2012 Blog bot DAX Blogs 0 24.07.2012 21:12
dynamics-ax: Interview with Microsoft's Lachlan Cash on his new role, AX 2012 and more Blog bot DAX Blogs 6 22.04.2011 14:55
emeadaxsupport: Running AX 2009 Client raises error: "An invalid directory structure for Microsoft Dynamics AX was detected" Blog bot DAX Blogs 0 01.04.2011 06:13
emeadaxsupport: How does the Dynamics AX Setup detect existing AOS Instances? Blog bot DAX Blogs 0 06.07.2010 17:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:09.