web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

how to download stream from url to local folder in d365 using x++

(0) ShareShare
ReportReport
Posted on by 958

Hi all,

I am having a word document uploaded to the temporary url. i want to download the document from the url to my local folder(folder creation using x++).

7506.Untitled1.jpg

i am using FileUploadTemporaryStorageResult result = File::SendFileToTempStore_GetResult to generate the url.

if i use browser.navigate in my job. it's downloading automatically in "Downloads" folder in system . i want to create my own folder and then save/download the document there

Any suggestions plss

I have the same question (0)
  • WillWU Profile Picture
    22,363 on at

    Hi Test Bot,

    Have you tried file::sendFileToUser(stream,filePathAndName).

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Hi Test_Bot,

    D365 can't see or create any folders on your workstation, just like any other websites (luckily) can't. The system can just ask the browser to open a download dialog, and from there on it's up to the browser and the user to choose a location that they want.

    You can set up the default download folder in your browser's settings.

  • TestBot Profile Picture
    958 on at

    Hi Wil Wu,

    In that method parameters, its given as only _filename. how can store/addmy local folder path. any example code or reference

    public static void SendFileToUser(System.IO.Stream stream, str fileName, ClassName fileUploadStrategyClassName = classstr(FileUploadTemporaryStorageStrategy))

       {

       }

  • WillWU Profile Picture
    22,363 on at

    Hi partner,

    I don't have an environment to test for you right now, please check this blog, you can try pass the full path in the second parameter.

    shootax.blogspot.com/.../x-d365fo-create-temp-file-and-save-to.html

  • TestBot Profile Picture
    958 on at

    Hi Wil Wu,

    I hav tried. but didn't got succceeded. can u provide any other suggestions.

  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    As Nikolaos explained, what you're trying to do isn't possible. The web server doesn't have access to files on client machines.

  • Suggested answer
    Sankar Ramalingam Profile Picture
    262 on at

    As a workaround, you could make your local folder to FTP and drop the file from D365 using below code.

    System.Byte[] bytes;
    System.Text.Encoding getUTF8;
    getUTF8 = System.Text.Encoding::get_UTF8();
    System.Object request,response,credential;
    System.Net.FtpWebRequest ftpRequest;
    System.IO.Stream requestStream;
    
    System.IO.StreamReader streamReader = new System.IO.StreamReader(stream);
    bytes = getUTF8.GetBytes(streamReader.ReadToEnd());
    
    request = System.Net.WebRequest::Create(new System.Uri("FTPURL"));
    ftpRequest = request; //Type casting object to ftpwebrequest object
    credential = new System.Net.NetworkCredential("UserName", "Password");
    ftpRequest.set_Credentials(credential);
    ftpRequest.set_ContentLength(bytes.get_Length());
    
    ftpRequest.set_Method('STOR');
    
    requestStream = ftpRequest.GetRequestStream();
    requestStream.Write(bytes,0,bytes.get_Length());
    requestStream.Close();

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans