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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Getting file path and file name from file explorer

(0) ShareShare
ReportReport
Posted on by 5

Does anyone have a solution for this problem?

I have a form with a string field for storing a full file name.

pastedimage1592568717941v1.png

The lookup works fine but does not give me the path only the file name:

pastedimage1592568840349v2.png

I have tried a couple of code variants with the same result:

public static FileName getFileBrowse()
{
Filename fileName;
FileUploadResultBase fileUpload;

fileUpload = File::GetFileFromUser() as FileUploadResultBase;
fileName = fileUpload.getFileName();
return fileName;
}

public static fileName getFileBrowseDialog(FilePath _filePath, str _fileTypesAccepted)
{

System.IO.Stream stream;
FileUploadBuild fileUpload;
DialogGroup dlgUploadGroup;
FileUploadBuild fileUploadBuild;
FormBuildControl formBuildControl;
Dialog dialog = new Dialog('Get file');
DialogField dialogFilename;
Filename filename;

dialog.filenameLookupInitialPath(_filePath);
dlgUploadGroup = dialog.addGroup('File name');
formBuildControl = dialog.formBuildDesign().control(dlgUploadGroup.name());
fileUploadBuild = formBuildControl.addControlEx(classstr(FileUpload), 'Upload');
fileUploadBuild.style(FileUploadStyle::MinimalWithFilename);
fileUploadBuild.fileTypesAccepted(_fileTypesAccepted);
if (dialog.run() && dialog.closedOk())
{
FileUpload fileUploadControl = dialog.formRun().control(dialog.formRun().controlId('Upload'));
FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult() as FileUploadTemporaryStorageResult;
filename = fileUploadControl.dataRelationPath(fileUploadControl.fileName());
return filename;
}

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at

    So, your user uploads a file and you would like to store the source path, as well as the file name, in D365? Is this correct?

    As far as I know, this is not possible because D365FO doesn't get any information about the folder. The browser (which is a program running locally on your computer) asks you for the folder and file, and once you choose a file, the browser sends the file to D365FO. D365FO doesn't get any information about the folders, it only receives the file. 

    Why would you want to store the folder name?

  • MPSHM Profile Picture
    5 on at

    The file is placed on a windows network and I do not need to upload it to AX365FO, only get the full name in a string field.

    The information is used in a xml file for integration with a third party windows client application.

    I am fully aware of the limitations in file handling on windows network in AX365FO cloud, but as told AX is not supposed to do anything with the file other than to know the full name.

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

    Most likely the user needs to copy-paste the path manually from Windows Explorer to D365FO.

  • SC-19081230-0 Profile Picture
    7 on at

    I have a similar request from a customer. 

    Yes I know FO can't access local files, etc.

    But we still need the complete filename.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans