Create directory

bartwyckmans
Member Posts: 39
Hi,
anyone know how to create a directory whitin Attain?
Thanks.
anyone know how to create a directory whitin Attain?
Thanks.
0
Comments
-
Hi.
I do not know if there is any better (more elegant :-)) way how to create directory from C/AL code than this, but I am using this ways:
both examples use standard DOS function MD (make dir)
1) you can use SHELL function like this:
SHELL('MD <<path of directory>>');
2) if first example does not work, you need to create a MS-DOS BAT file and call it from C/AL
filBat is C/AL variable, type FILE
creating file:
filBat.CREATE(<<some path to temp file>> + '<<filename.bat>>');
filBat.WRITEMODE(TRUE);
filBat.TEXTMODE(TRUE);
filBat.WRITE('@ECHO OFF');
filBat.WRITE('MD ' + <<path of direcory, which will be created>>');
filBat.WRITE('@ECHO OFF'); /// important, without this command, on Win9X system after execution of this batch remains opened window of finished job
filBat.CLOSE;
call batch file
SHELL('<<batch file>>');
delete batch file, which is redundand at this time, because directory was created
ERASE(<<batch file>>);
exact description, syntax and parameters of all C/AL statements can be found in on-line help for C/AL
I think I helped U
If anyone knows better solution of this problem, write it there.Martin Bokůvka, AxiomProvis0 -
thank you !!0
-
Great solution! =D> =D>
I use it like described except instead of MD I use the XCOPY command.
I create a new job-directory by copying (XCOPY) a default directory to a new directory with the name of the job no.
Works like a charm! 8)
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
Use the 'Windows Script Host Object Model'.FileSystemObject'
CreateFolder(NewFolder : Text[100]) : Boolean
IF ISCLEAR(FileSystem) THEN
IF NOT CREATE(FileSystem) THEN
EXIT;
FileSystem.CreateFolder(NewFolder);There are no bugs - only undocumented features.0 -
bbrown wrote:Use the 'Windows Script Host Object Model'.FileSystemObject'
CreateFolder(NewFolder : Text[100]) : Boolean
IF ISCLEAR(FileSystem) THEN
IF NOT CREATE(FileSystem) THEN
EXIT;
FileSystem.CreateFolder(NewFolder);
For creating 1 folder this (filesystem) is the easiest solution. But for copying 24 folders I think the solution with the batchfile and xcopy works faster. Or is it possible to do this with FileSystem? I'll have a look myself.
Btw. I have used WindowsShell.Explore(FolderName) for opening a folder like the way you described.
And I added a CLEAR(FileSystem); before IF ISCLEAR, because else I couldn't open the folder two times from the same form.
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
tinoruijs wrote:bbrown wrote:Use the 'Windows Script Host Object Model'.FileSystemObject'
CreateFolder(NewFolder : Text[100]) : Boolean
IF ISCLEAR(FileSystem) THEN
IF NOT CREATE(FileSystem) THEN
EXIT;
FileSystem.CreateFolder(NewFolder);
For creating 1 folder this (filesystem) is the easiest solution. But for copying 24 folders I think the solution with the batchfile and xcopy works faster. Or is it possible to do this with FileSystem? I'll have a look myself.
Btw. I have used WindowsShell.Explore(FolderName) for opening a folder like the way you described.
And I added a CLEAR(FileSystem); before IF ISCLEAR, because else I couldn't open the folder two times from the same form.
I am using this code to create a group of over 100 folders.There are no bugs - only undocumented features.0 -
bbrown wrote:tinoruijs wrote:bbrown wrote:Use the 'Windows Script Host Object Model'.FileSystemObject'
CreateFolder(NewFolder : Text[100]) : Boolean
IF ISCLEAR(FileSystem) THEN
IF NOT CREATE(FileSystem) THEN
EXIT;
FileSystem.CreateFolder(NewFolder);
For creating 1 folder this (filesystem) is the easiest solution. But for copying 24 folders I think the solution with the batchfile and xcopy works faster. Or is it possible to do this with FileSystem? I'll have a look myself.
Btw. I have used WindowsShell.Explore(FolderName) for opening a folder like the way you described.
And I added a CLEAR(FileSystem); before IF ISCLEAR, because else I couldn't open the folder two times from the same form.
I am using this code to create a group of over 100 folders.
Ok. Are there files in those folders?
If so, you copy them by using file.COPY?
Thanks for the input!
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
In my situation I am creating a bunch of files in a group of folders. The above code is used to create any folders that are missing. The folder names are based on records in Navision.
I am then using
FileSystem.MoveFile(Path + Filename, NewPath + Filename);
to move the files to another folder.There are no bugs - only undocumented features.0 -
Ok. Good solution! 8)
In the meanwhile I saw FileSystem has more than enough options to do everything I want.
Tino Ruijs
Microsoft Dynamics NAV specialist0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions