Moving files from network drive(Only accessible on client) to locally (on server).

PhoguePhogue Posts: 13Member
Hi.

I'm currently trying to browse a network drive to attach some files to a mail.

Currently I'm using the DotNet System.Object and System.IO.Directory and System.Collections.Generic.List to find the filepaths in the following way:

SysObj := SysDir.GetFiles(DirectoryPath);
SysList := SysList.List;
SysList.AddRange(SysObj);

FOR j:= 1 TO SysList.Count DO BEGIN
CurrentFile := FORMAT(SysList.Item(j-1));
END;

Since only the NAV clients have access to the network drives in which the files exist, RunOnClient has to be set to true for these DotNet data type variables.

I want to move these files to a drive on the same server the NAV server runs on, but I can't simply use System.IO.Directory.Move(file1,file2), since the client won't have access to the server's drives.

Is there any smart way of going about this, since I can't set the File datatype to RunOnClient = true?

Thank you in advance.

Best Answer

  • MaaaxMaaax Strasbourg, FrancePosts: 14
    Accepted Answer
    @phogue If i'm not wrong, you should be able to handle this with the CUs
    • "3-Tier Automation Mgt." with BlobImport and BlobExport
    • "Common Dialog Management" for User File Selecting Window.
    Maxime JUND
    Talent Business Solutions
    Technical Expert of Microsoft Dynamics 365 Business Central
    Website | Mail | LinkedIn

Answers

  • SanderDkSanderDk Posts: 249Member
    Hello @Phenno
    What version of NAV are you running?

    If you run a newer version of NAV or BC, then you can use Codeunit 419 File Management.

    There is a function called UploadFileSilentToServerPath, where you can pass your client path and your server path.

    This will upload the file.
    For help, do not use PM, but use forum instead, perhaps other people have the same question, or better answers.
  • MaaaxMaaax Strasbourg, FrancePosts: 14Member
    +1 SanderDk.
    The CU 419 is the holy bible for file handling :wink:
    Maxime JUND
    Talent Business Solutions
    Technical Expert of Microsoft Dynamics 365 Business Central
    Website | Mail | LinkedIn
  • PhoguePhogue Posts: 13Member
    edited 2019-07-08
    SanderDk wrote: »
    Hello
    What version of NAV are you running?

    @SanderDk Thanks for the response, I'm currently on 6.02, with no File Management CU unfortunately, but I'll grab the function code from a newer version, and try using it in the 6.02, since it only requires dotnet objects and not data types such as blobs.
  • MaaaxMaaax Strasbourg, FrancePosts: 14Member
    Accepted Answer
    @phogue If i'm not wrong, you should be able to handle this with the CUs
    • "3-Tier Automation Mgt." with BlobImport and BlobExport
    • "Common Dialog Management" for User File Selecting Window.
    Maxime JUND
    Talent Business Solutions
    Technical Expert of Microsoft Dynamics 365 Business Central
    Website | Mail | LinkedIn
Sign In or Register to comment.