Folder exist
jensthomsen
Member Posts: 173
Hi
I need to check if a certain folder exist - that is, does C:\temp\MyFolder\ exist. What would be the easiest way of doing this?
Jens
I need to check if a certain folder exist - that is, does C:\temp\MyFolder\ exist. What would be the easiest way of doing this?
Jens
0
Comments
-
Directory is record type and subtype is File
clear(Directory); Directory.setrange(Path,'C:\temp\'); FolderExists := Directory.findfirst;
0 -
Hi ara3n
Thats not quite good enough. If the folder doesn't exist, you will still get an error...0 -
ara3n wrote:Directory is record type and subtype is File
clear(Directory); Directory.setrange(Path,'C:\temp\'); FolderExists := Directory.findfirst;
Hello,
I did not get an error using SETFILTER..Directory.SETFILTER(Path,'C:\'); // Works better than CLEAR :) IF Directory.findfirst THEN; // Works better than CLEAR :) Directory.SETFILTER(Path,'C:\temp\'); Directory.SETRANGE("Is a file",false); MESSAGE('%1',Directory.findfirst);Hope this helpes you..Met vriendelijke groet, best regards,
Rvduuren0 -
Hi rvduuren
As far as I understand, your check is if there exists subfolders in the folder c:\temp...? I want to check if c:\temp\ exists...0 -
jensthomsen wrote:Hi rvduuren
As far as I understand, your check is if there exists subfolders in the folder c:\temp...? I want to check if c:\temp\ exists...
Hello Jens,
I'm not checking any subfolders with above code, just if c:\temp exists. But you can also use FileSystemObject:Globals:Folder - Automation - 'Windows Script Host Object Model'.FileSystemObject create(Folder); message('%1',Folder.FolderExists('c:\temp')); clear(Folder);Met vriendelijke groet, best regards,
Rvduuren0 -
-
ajhvdb wrote:if EXISTS(C:\nul') then ... should work too.
This won't work. Exists only is used for files not folder.0 -
-
What is the difference?0
-
I tried it, and I also tested it

Doesn't work, it always returns FALSE0 -
I'm using it in production and it does work...it was working in the days of MSDOS but maybe in other countries not.
create a button and put this in the push event:message('%1', EXISTS('C:\WINDOWS\nul')); message('%1', EXISTS('D:\nul')); message('%1', EXISTS('X:\WINDOWS\nul')); message('%1', EXISTS('D:\DATA\nul'));
Run it and if you have a
drive and
\DATA, it answers:
Yes
Yes
No
Yes0 -
OBJECT Form 60000 Exist { OBJECT-PROPERTIES { Date=12/10/07; Time=[ 1:30:23 PM]; Modified=Yes; Version List=; } PROPERTIES { Width=2640; Height=990; } CONTROLS { { 1000000000;CommandButton;220;220;2200;550 ;CaptionML=ENU=Click; OnPush=BEGIN MESSAGE('%1',EXISTS('C:\Windows\nul')); MESSAGE('%1',EXISTS('C:\Dummy\nul')); END; } } CODE { BEGIN END. } }The part that makes this work is "nul", with just one 'l', at the end of the folder path
<edit>modified post with updated information</edit>0 -
-
that is some undocumented feature, I hope will be supported in 6.0?
Since the exists will run in service tier .net dll.
Learning something new every day.0 -
You can use the automation 'Microsoft Scripting Runtime'.FileSystemObject. Use the function FolderExists. Just pass the path and it will return a boolean value weather the certain folder exists or not.Navision noob....0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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

