Monday, August 8, 2016

Create New Directory using Dynamics NAV C/AL Code

Hello Friends,

Use the following code to create the new directory (folder) using Dynamics NAV C/AL Code.












    PROCEDURE CreateNewDir_gFnc@33027956(OldFilePath_iTxt@33027923 : Text;NewDirectoryName_iTxt@33027924 : Text[50];VAR AttDir_vTxt@33027927 : Text);
    VAR
      DirectoryHelper@33027920 : DotNet "'mscorlib'.System.IO.Directory" RUNONCLIENT;
      directory@33027921 : Text;
      FileMgt_lCdu@33027922 : Codeunit 419;
      PathHelper@33027925 : DotNet "'mscorlib'.System.IO.Path";
      SystemDirectoryServer_lDnt@33027926 : DotNet "'MSCORLIB'.System.IO.Directory";
    BEGIN
      // Get the directory from the OldFilePath, if directory is empty it will just use the current location.
      directory := FileMgt_lCdu.GetDirectoryName(OldFilePath_iTxt);

      NewDirectoryName_iTxt := DELCHR(NewDirectoryName_iTxt,'=','#%&*:<>?\/{|}~');

      // create the sub directory name is name is given
      IF NewDirectoryName_iTxt <> '' THEN BEGIN
        directory := PathHelper.Combine(directory,NewDirectoryName_iTxt);

        IF NOT SystemDirectoryServer_lDnt.Exists(directory) THEN
          DirectoryHelper.CreateDirectory(directory);
      END;

      AttDir_vTxt := directory;
    END;


Download the sample code at following location:
https://1drv.ms/t/s!An8nhANnLJmtiS-A90kgwaGLFlPC

Thank you for reading.
I wish it will help you in future.

Please write a comment here if you need any help.

Keep Sharing...Keep Growing....

6 comments:

  1. There was a time when adding community features to your site means the ability to participate in forums, chat with people in a window, or post comments. Though these practices are still common in the Web today.ipucum

    ReplyDelete
  2. how to create a folder in google drive through navision. please help on this

    ReplyDelete
  3. No doubt this is an excellent post I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post. available business names

    ReplyDelete
  4. this is really nice to read..informative post is very good to read..thanks a lot!
    cool names for companies

    ReplyDelete
  5. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. Sharepoint employee directory

    ReplyDelete