Automation Return Value
Albertvh
Member Posts: 516
Hi
Could anybody tell me what the return part of the statement should be
[IFOLDER CreateFolder :=] FileSystem.CreateFolder(BSTR Path)
FileSystem is automation 'Microsoft Scripting Runtime'.FileSystemObject
Thanks
Albert
Could anybody tell me what the return part of the statement should be
[IFOLDER CreateFolder :=] FileSystem.CreateFolder(BSTR Path)
FileSystem is automation 'Microsoft Scripting Runtime'.FileSystemObject
Thanks
Albert
0
Answers
-
you can set the Return Value to the IFOLDER Object. And work with the properties / functions of this.
WSHFSO --> 'Windows Script Host Object Model'.FileSystemObject WSHFolder --> 'Windows Script Host Object Model'.Folder WSHFolder := FileSystem.CreateFolder('C:\MyFolder); //example message('The Foldername is %1',WSHFolder.Name);
RegardsDo you make it right, it works too!0 -
Hi Garak,
Thanks for your response.I have this scenario.
I have a table with a directory field eg \\net\document\template
when I use the code as you have suggested I get this errorThis message is for C/AL programmers.
An exception was raised in method CreateFolder. The OLE control or Automation serverhas returned error (HRESULT)
-2147352567
Thecomponent did not provide the exception description
Thanks
Albert0 -
Hi Albert,
that was only an example based on your question.
Other question. What do you want (whats the reason) to do with the UNCPath and the directory?
You whish to open the folder? Access all files in the folder or what?
RegardsDo you make it right, it works too!0 -
Hi Garak,
Sorry was not in yesterday.
I check if the directory exists and if not I try and create it, however it will not create a folder \\net\Document\Template so I was trying to avoid the error. I can't use an If statement either.
I do know that I can create the folders one by one. ie \\net\Document and then \\net\Document\Template
I think I will change the logic and give the user an error telling them that the directory doesn't exist.
Albert0 -
if isclear(WSHFSO) then create(WSHFSO); if not WSHFSO.FolderExists('C:\temp\Test') then begin WSHFolder := WSHFSO.CreateFolder('C:\temp\Test'); end; WSHFolder := WSHFSO.GetFolder('C:\temp\Test');Do you make it right, it works too!0 -
Hi Garak,
I did try to do that but still the error popped up.
Albert0 -
do you have access to create a folder in the directory?Do you make it right, it works too!0
-
Hi Garak,
What I want to do is check if the directory exists, I have permission to create folders, however the base folder does not exist in this case Document. So if I try and create \\net\Document\Template I get the error, it is trying to create the folder \\net\Document\Template in one step instead of two.
Albert0 -
CreateFolder can only create one folder and not a foldertree.
So you must check if the base exist and then create the other folders.
If the base doesn't exist, create it and then create the other folders.
\\net\ <-- hope it's the UNC Path and not a drive letter ;-)Do you make it right, it works too!0 -
Hi Garak,
I know that but I just wanted to check if there was a return code but now I know there isn't I will change my code.
Thanks for your help. I'll mark it as solved.
Albert0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 324 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