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 error
This 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
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?
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.
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');
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.
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 ;-)
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.
Answers
Regards
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 error
Thanks
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?
Regards
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.
Albert
I did try to do that but still the error popped up.
Albert
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.
Albert
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 ;-)
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.
Albert