Dynamics 365 Business Central: How to quickly get the extension name, file name without extension, and Media (MIME) types from an uploaded file

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share another mini tip about Business Central, how to quickly get the extension name, file name without extension, and Media (MIME) types from an uploaded file.
In Business Central, we sometimes need to upload a file from the client computer to the corresponding server. Used to process data or save files directly. (The client computer is the computer that is running a browser that accesses the web client)

At this time we will can the following method: File.UploadIntoStream() Method

Here are some recent solutions:

PS: The standard Attached Documents functionality also uses this method.

InitiateUploadFile():

local procedure ImportWithFilter:

FileManagement.BLOBImportWithFilter():

UploadIntoStream(DialogCaption, ”, FileFilter, Name, NVInStream):

So when we upload a file, in addition to the file content, if we want to record extension name, file name without extension, and Media (MIME) types, is there any simple way? Yes. This can also be found as a reference in standard methods.

Validate("File Extension", FileManagement.GetExtension(IncomingFileName));
Validate("File Name", CopyStr(FileManagement.GetFileNameWithoutExtension(IncomingFileName), 1, MaxStrLen("File Name")));

codeunit 419 “File Management”:

Let’s look at a simple example.

Test video:

Very simple, give it a try!!!😁

PS: There is also a method to create a file name from the name and extension.

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL