Create a folder / path

Hi from Cologne, today my question may be silly but I can’t help myself: how to create a folder / a whole path in navision? How to check if the folder / the path exist? I know the EXISTS-command but in my eyes this only helps if files are checked. Thank you in advance! Andreas, Cologne / Germany

Hello, You could check if the folder exists by using the file virtual table and use filters. Then you could create the folder by using the SHELL function.

Hi Using automation and Microsoft Scripting Runtime you could try this: Name DataType Subtype Length Au-ScriptFilesystem Automation 'Microsoft Scripting Runtime'.FileSystemObject Au-ScriptFolder Automation 'Microsoft Scripting Runtime'.Folder Au-ScriptFolders Automation 'Microsoft Scripting Runtime'.Folders MakeFolder(BaseFolder : Text[250];NewFolder : Text[250]) CREATE ("Au-ScriptFilesystem"); IF NOT "Au-ScriptFilesystem".FolderExists(BaseFolder) THEN ERROR ('Base folder does not exist'); "Au-ScriptFolder" := "Au-ScriptFilesystem".GetFolder(BaseFolder); "Au-ScriptFolders" := "Au-ScriptFolder".SubFolders; IF NOT "Au-ScriptFilesystem".FolderExists(BaseFolder + '\' + NewFolder) THEN "Au-ScriptFolders".Add (NewFolder); Stefan

Thank you very much. Could you explain how to use the File Virtual Table? Never worked with it! SHELL works! I tested! Great!

It’s actually quite simple (once you learn how) here is a sample code: FileUpdate; TabFile.SETRANGE(Path,xPath); TabFile.SETRANGE(“Is a file”,TRUE); // if it’s a file TabFile.SETFILTER(Name,’%1’,xFileName); // to check if a file exists IF TabFile.FIND(’-’) THEN BEGIN ------------- End; The previous example gives let’s you find a file. If you change the setrange to false: TabFile.SETRANGE(“Is a file”,FALSE); Then it’s a directory. There is also a small function that i call just to make sure that this table is refreshed properly: Function FileUpdate() //Recors 2000000002 TabFileAux.SETRANGE(Path,‘c:’); IF TabFileAux.FIND(’-’) THEN; And that is… Cheers