Need to store a file stream into a local file path in d365fo

Hi All,

I am fetching a file stream from temp blob storage and I wanted to store it in a local path through code. I have tried the below code, but it is prompting a saveAs dialog whether to save the file to download folder, but I want the file stream to be saved to a specific path automatically through code itself. Please suggest a solution for this issue.

 public static void main(Args _args)
    {
        Str1260 fileUrl;
        container readCon;
        FilePath  tempDir = "C:\\Temp\\DIXF\\file.txt";
        
        FileUploadTemporaryStorageResult result = File::GetFileFromUser() as FileUploadTemporaryStorageResult;
        if (result && result.getUploadStatus())
        {
            fileUrl = result.getDownloadUrl();
            //info(fileUrl);
            readCon = Binary::constructFromMemoryStream(result.openResult()).getContainer();
            
           System.IO.StreamReader sReader = new System.IO.StreamReader(result.openResult());

           // Set file contentn string
          str  fileContent = sReader.ReadToEnd();

           // Save file
           File::SendStringAsFileToUser(fileContent, tempDir);
       

        }
    }

Thanks in Advance,

Gopinath M.

Parents
  • Hi All,

    File upload to blob storage is successful and download it with a save As dialog is happening but I want to directly save that blob storage file into local file path without prompting for our selection to store. Can Anyone suggest a solution to achieve this through code.

    Thanks in Advance,

    Gopinath M

Reply Children
No Data
Related
Recommended