---
id: object/codeunit/419
type: object
title: Codeunit 419 "File Management"
summary: Codeunit 419 "File Management" in Base Application (System.IO). 49 public procedures, 7 events. Present since at least BC23, still in BC30, changed in BC27.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "27"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 526060447ddb884f0973394103e749a62aab9cff3d333b6bc63cb4bd0dd6d390
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Modules/System/FileOperations/FileManagement.Codeunit.al
    title: src/Layers/W1/BaseApp/Modules/System/FileOperations/FileManagement.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 419
name: File Management
namespace: System.IO
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "27"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 58
  events: 7
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 3
  called_by: 103
  implements: 0
---

# Codeunit 419 "File Management"

> Codeunit 419 "File Management" in Base Application (System.IO). 49 public procedures, 7 events. Present since at least BC23, still in BC30, changed in BC27.

Base Application · System.IO · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Modules/System/FileOperations/FileManagement.Codeunit.al) · facts from BC29

## Events published

- `OnAfterGetToFilterTextSetOutExt(FileName: Text; var OutExt: Text)` (integration)
- `OnAfterDownloadHandler(var ToFolder: Text; ToFileName: Text; FromFileName: Text; var Downloaded: Boolean)` (integration)
- `OnBeforeBlobExport(var TempBlob: Codeunit "Temp Blob"; Name: Text; CommonDialog: Boolean; var IsHandled: Boolean; var Result: Text)` (integration)
- `OnBeforeBlobExportWithEncoding(var TempBlob: Codeunit "Temp Blob"; Name: Text; CommonDialog: Boolean; Encoding: TextEncoding; var Result: Text; var IsHandled: Boolean)` (integration)
- `OnBeforeDownloadHandler(var ToFolder: Text; ToFileName: Text; FromFileName: Text; var IsHandled: Boolean; var Downloaded: Boolean)` (integration)
- `OnBeforeUploadFileWithFilter(var ServerFileName: Text; WindowTitle: Text[50]; ClientFileName: Text; FileFilter: Text; ExtFilter: Text; var IsHandled: Boolean)` (integration)
- `OnBeforeDownloadFromStreamHandler(var ToFolder: Text; ToFileName: Text; FromInStream: InStream; var IsHandled: Boolean)` (integration)

## Procedures

- `BLOBImport(var TempBlob: Codeunit "Temp Blob"; Name: Text): Text`
- `BLOBImportWithFilter(var TempBlob: Codeunit "Temp Blob"; DialogCaption: Text; Name: Text; FileFilter: Text; ExtFilter: Text): Text`
- `BLOBExportWithEncoding(var TempBlob: Codeunit "Temp Blob"; Name: Text; CommonDialog: Boolean; Encoding: TextEncoding): Text`
- `BLOBExport(var TempBlob: Codeunit "Temp Blob"; Name: Text; CommonDialog: Boolean): Text`
- `ServerTempFileName(FileExtension: Text): Text`
- `DownloadTempFile(ServerFileName: Text): Text`
- `UploadFile(WindowTitle: Text[50]; ClientFileName: Text): Text`
- `UploadFileWithFilter(WindowTitle: Text[50]; ClientFileName: Text; FileFilter: Text; ExtFilter: Text): Text`
- `Magicpath(): Text`
- `DownloadHandler(FromFile: Text; DialogTitle: Text; ToFolder: Text; ToFilter: Text; ToFile: Text): Boolean`
- `DownloadFromStreamHandler(FromInStream: InStream; DialogTitle: Text; ToFolder: Text; ToFilter: Text; ToFile: Text): Boolean`
- `CopyServerFile(SourceFileName: Text; TargetFileName: Text; Overwrite: Boolean)`
- `ServerFileExists(FilePath: Text): Boolean`
- `DeleteServerFile(FilePath: Text): Boolean`
- `ServerDirectoryExists(DirectoryPath: Text): Boolean`
- `ServerCreateDirectory(DirectoryPath: Text)`
- `ServerCreateTempSubDirectory(): Text`
- `ServerRemoveDirectory(DirectoryPath: Text; Recursive: Boolean)`
- `GetFileName(FilePath: Text): Text`
- `GetSafeFileName(FileName: Text): Text`
- `GetPathWithSafeFileName(InFilePath: Text): Text`
- `GetFileNameWithoutExtension(FilePath: Text): Text`
- `HasExtension(FilePath: Text): Boolean`
- `GetFileNameMimeType(FileName: Text): Text`
- `GetDirectoryName(FileName: Text): Text`
- `GetServerDirectoryFilesList(var NameValueBuffer: Record "Name/Value Buffer"; DirectoryPath: Text)`
- `GetServerDirectoryFilesListInclSubDirs(var TempNameValueBuffer: Record "Name/Value Buffer" temporary; DirectoryPath: Text)`
- `GetServerFileProperties(FullFileName: Text; var ModifyDate: Date; var ModifyTime: Time; var Size: BigInteger)`
- `CombinePath(BasePath: Text; Suffix: Text): Text`
- `BLOBImportFromServerFile(var TempBlob: Codeunit "Temp Blob"; FilePath: Text)`
- `BLOBExportToServerFile(var TempBlob: Codeunit "Temp Blob"; FilePath: Text)`
- `InstreamExportToServerFile(Instream: InStream; FileExt: Text): Text`
- `TempBlobToServerFile(var TempBlob: Codeunit "Temp Blob"; FileExt: Text): Text[250]` (internal)
- `CreateAndWriteToServerFile(FileContent: Text; FileExt: Text): Text`
- `GetToFilterText(FilterString: Text; FileName: Text): Text`
- `GetExtension(Name: Text): Text`
- `IsValidFileName(FileName: Text): Boolean`
- `ValidateFileExtension(FilePath: Text; ValidExtensions: Text)`
- `CreateFileNameWithExtension(FileNameWithoutExtension: Text; Extension: Text): Text`
- `Ansi2SystemEncoding(Destination: OutStream; Source: InStream)`
- `Ansi2SystemEncodingTxt(Destination: OutStream; Source: Text)`
- `StripNotsupportChrInFileName(InText: Text): Text`
- `ExportImage(ImagetPath: Text; ToFile: Text)`
- `IsClientDirectoryEmpty(Path: Text): Boolean`
- `IsServerDirectoryEmpty(Path: Text): Boolean`
- `GetFileContents(FilePath: Text): Text`: Gets the file contents as text from the file path provided in UTF8 text encoding.
- `GetFileContents(FilePath: Text; Encoding: TextEncoding): Text`: Gets the file contents as text from the file path provided in the requested text encoding.
- `IsAllowedPath(Path: Text; SkipError: Boolean): Boolean`
- `AppendFileNameWithIndex(OriginalFileName: Text; AppendIndex: Integer): Text`

Plus 2 local procedures.

## Triggers

OnRun

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 4100 "Temp Blob"](../codeunit/4100.md) (6 calls: `BLOBExport → CreateInStream`, `BLOBExportToServerFile → CreateInStream`, `BLOBExportWithEncoding → CreateInStream`, …)
- [Codeunit 1299 "Web Request Helper"](../codeunit/1299.md) (1 call: `IsAllowedPath → IsHttpUrl`)
- [Codeunit 457 "Environment Information"](../codeunit/457.md) (1 call: `IsAllowedPath → IsSaaS`)

## Called by

- [Codeunit 8614 "Config. XML Exchange"](../codeunit/8614.md) (19 calls: `DecompressPackage → ServerTempFileName`, `ExportPackageXML → DownloadHandler`, `ExportPackageXML → GetDirectoryName`, …)
- [Table 5062 "Attachment"](../table/5062.md) (17 calls: `ExportAttachmentToClientFile → DeleteServerFile`, `ExportAttachmentToClientFile → Magicpath`, `ExportAttachmentToClientFile → ServerTempFileName`, …)
- [Codeunit 8800 "Custom Layout Reporting"](../codeunit/8800.md) (15 calls: `AddFileToClientZip → ServerTempFileName`, `GenerateFileName → AppendFileNameWithIndex`, `GenerateFileName → CombinePath`, …)
- [Table 77 "Report Selections"](../table/77.md) (15 calls: `DoSaveReportAsHTMLInTempBlob → BLOBExportToServerFile`, `DoSaveReportAsHTMLInTempBlob → BLOBImportFromServerFile`, `DoSaveReportAsHTMLInTempBlob → ServerTempFileName`, …)
- [Table 370 "Excel Buffer"](../table/370.md) (13 calls: `CreateBook → IsAllowedPath`, `CreateBook → ServerTempFileName`, `GetFriendlyFilename → StripNotsupportChrInFileName`, …)
- [Codeunit 5052 "AttachmentManagement"](../codeunit/5052.md) (9 calls: `DeliverEmailWithAttachmentViaExchange → DeleteServerFile`, `DeliverHTMLEmailViaExchange → DeleteServerFile`, `DeliverHTMLEmailViaExchange → ServerTempFileName`, …)
- [Codeunit 1652 "Add-in Manifest Management"](../codeunit/1652.md) (7 calls: `DownloadManifestToClient → CopyServerFile`, `DownloadManifestToClient → DownloadHandler`, `DownloadMultipleManifestsToClient → DownloadFromStreamHandler`, …)
- [Codeunit 5069 "Word Template Interactions"](../codeunit/5069.md) (7 calls: `ExecuteMerge → DeleteServerFile`, `ExecuteMerge → ServerTempFileName`, `Merge → DownloadFromStreamHandler`, …)
- [Codeunit 5503 "Graph Mgt - Attachment Buffer"](../codeunit/5503.md) (7 calls: `FileNameToNameAndExtension → GetExtension`, `FileNameToNameAndExtension → GetFileNameWithoutExtension`, `InsertFromTempAttachmentEntityBufferToDocumentAttachment → GetExtension`, …)
- [Codeunit 8610 "Questionnaire Management"](../codeunit/8610.md) (7 calls: `CreateConfigQuestionnaireXMLFile → ServerTempFileName`, `CreateSchemaFile → ServerTempFileName`, `ExportQuestionnaireAsXML → DownloadHandler`, …)
- [Codeunit 6952 "Exp. Attach. Buffer Handler"](../codeunit/6952.md) (6 calls: `PropagateInsertAttachment → GetExtension`, `PropagateInsertAttachment → GetFileNameWithoutExtension`, `PropagateInsertAttachment → IsValidFileName`, …)
- [Report 29 "Export Acc. Sched. to Excel"](../report/29.md) (6 calls: `SetUseExistingTemplate → CreateFileNameWithExtension`, `SetUseExistingTemplate → InstreamExportToServerFile`, `UploadClientFile → GetFileName`, …)
- [Table 1173 "Document Attachment"](../table/1173.md) (6 calls: `Export → BLOBExport`, `InsertAttachment → GetExtension`, `InsertAttachment → GetFileNameWithoutExtension`, …)
- [Table 130400 "CAL Test Suite"](../table/130400.md) (6 calls: `ExportTestSuiteResult → BLOBExport`, `ExportTestSuiteResult → ServerTempFileName`, `ExportTestSuiteSetup → BLOBExport`, …)
- [Codeunit 1292 "Trace"](../codeunit/1292.md) (5 calls: `LogStreamToTempFile → BLOBExportToServerFile`, `LogStreamToTempFile → ServerTempFileName`, `LogTextToTempFile → ServerTempFileName`, …)
- [Codeunit 130404 "CAL Test Project Mgt."](../codeunit/130404.md) (5 calls: `Export → DownloadHandler`, `Export → IsAllowedPath`, `Export → ServerTempFileName`, …)
- [Codeunit 1919 "MigrationQB Data Reader"](../codeunit/1919.md) (5 calls: `UnzipFile → GetDirectoryName`, `UnzipFile → GetServerDirectoryFilesListInclSubDirs`, `UnzipFile → ServerCreateTempSubDirectory`, …)
- [Codeunit 9170 "Conf./Personalization Mgt."](../codeunit/9170.md) (5 calls: `DownloadProfileConfigurationPackage → DeleteServerFile`, `DownloadProfileConfigurationPackage → DownloadHandler`, `DownloadProfileConfigurationPackage → ServerTempFileName`, …)
- [Table 1235 "XML Buffer"](../table/1235.md) (5 calls: `Download → DeleteServerFile`, `Download → DownloadHandler`, `Download → ServerTempFileName`, …)
- [Codeunit 20113 "AMC Bank Exp. CT Hndl"](../codeunit/20113.md) (4 calls: `DecodePaymentData → BLOBImportFromServerFile`, `DecodePaymentData → IsAllowedPath`, `DecodePaymentData → ServerTempFileName`, …)
- [Codeunit 20114 "AMC Bank Imp.STMT. Hndl"](../codeunit/20114.md) (4 calls: `EncodeBankStatementFile → BLOBExportToServerFile`, `EncodeBankStatementFile → IsAllowedPath`, `EncodeBankStatementFile → ServerTempFileName`, …)
- [Codeunit 2020 "Image Analysis Management"](../codeunit/2020.md) (4 calls: `SetBlob → BLOBExportToServerFile`, `SetBlob → ServerTempFileName`, `SetImagePath → IsAllowedPath`, …)
- [Codeunit 452 "Report Distribution Management"](../codeunit/452.md) (4 calls: `CreateOrAppendZipFile → GetFileNameWithoutExtension`, `DownloadPdfOnClient → DownloadTempFile`, `SaveFileOnClient → BLOBExport`, …)
- [Codeunit 8618 "Config. Excel Exchange"](../codeunit/8618.md) (4 calls: `BuildDataSetForPackageTable → ServerTempFileName`, `ExportExcel → BLOBExport`, `ExportExcel → BLOBExportToServerFile`, …)
- [Codeunit 9660 "Report Layouts Impl."](../codeunit/9660.md) (4 calls: `CreateLayoutMime → GetExtension`, `ExportReportLayout → BLOBExport`, `ExportReportLayout → BLOBExportWithEncoding`, …)
- [Report 88 "VAT- VIES Declaration Disk"](../report/88.md) (4 calls: `OnPostReport → DeleteServerFile`, `OnPostReport → DownloadHandler`, `OnPostReport → GetToFilterText`, …)
- [Table 9650 "Custom Report Layout"](../table/9650.md) (4 calls: `ExportReportLayout → BLOBExport`, `ExportSchema → BLOBExport`, `ImportReportLayout → BLOBImportWithFilter`, …)
- [Codeunit 134 "Import Attachment - Inc. Doc."](../codeunit/134.md) (3 calls: `SaveDocumentAttachment → GetExtension`, `SaveDocumentAttachment → GetFileNameWithoutExtension`, `UploadFile → BLOBImportWithFilter`)
- [Codeunit 1410 "Doc. Exch. Service Mgt."](../codeunit/1410.md) (3 calls: `ExtractAdditionalAttachment → GetExtension`, `ExtractAdditionalAttachment → IsAllowedPath`, `ExtractAdditionalAttachment → ServerTempFileName`)
- [Codeunit 1630 "Office Management"](../codeunit/1630.md) (3 calls: `AttachDocument → GetExtension`, `AttachDocument → ServerTempFileName`, `GetContent → BLOBImportFromServerFile`)
- [Codeunit 1806 "Excel Data Migrator"](../codeunit/1806.md) (3 calls: `ImportExcelData → UploadFile`, `ImportExcelDataByFileName → ValidateFileExtension`, `ImportExcelDataStream → GetToFilterText`)
- [Codeunit 431 "IC Outbox Export"](../codeunit/431.md) (3 calls: `AddBatchProcessingArtifact → BLOBImportFromServerFile`, `DownloadBatchFiles → DownloadFromStreamHandler`, `SendToExternalPartner → DownloadTempFile`)
- [Codeunit 6223 "OpenXML Management"](../codeunit/6223.md) (3 calls: `CreateSchemaConnection → GetFileName`, `ExtractXMLSchema → IsAllowedPath`, `ExtractXMLSchema → ServerTempFileName`)
- [Codeunit 8361 "Financial Report Export Job"](../codeunit/8361.md) (3 calls: `ExportExcel → CreateFileNameWithExtension`, `ExportPackageSchedule → CreateFileNameWithExtension`, `ExportPdf → CreateFileNameWithExtension`)
- [Codeunit 9610 "XSD Parser"](../codeunit/9610.md) (3 calls: `GetSchemaLocation → CombinePath`, `GetSchemaLocation → GetDirectoryName`, `ParseSchemaReferenceDefinition → GetFileName`)
- [Table 130 "Incoming Document"](../table/130.md) (3 calls: `AddAttachmentFromServerFile → GetExtension`, `AddAttachmentFromStream → GetFileNameWithoutExtension`, `AddXmlAttachmentFromXmlText → GetFileNameWithoutExtension`)
- [Table 31 "Item Picture Buffer"](../table/31.md) (3 calls: `LoadZIPFile → GetExtension`, `LoadZIPFile → GetFileName`, `LoadZIPFile → GetFileNameWithoutExtension`)
- [Table 9600 "XML Schema"](../table/9600.md) (3 calls: `ExportSchema → BLOBExport`, `LoadSchema → BLOBImport`, `LoadSchema → GetFileName`)
- [Codeunit 1181 "Prvacy Data Mgmt Excel"](../codeunit/1181.md) (2 calls: `OnRun → ServerFileExists`, `OnRun → ServerTempFileName`)
- [Codeunit 1259 "Certificate Management"](../codeunit/1259.md) (2 calls: `UploadAndVerifyCert → BLOBImportWithFilter`, `UploadAndVerifyCert → GetFileName`)
- [Codeunit 1676 "MS - Quickbooks Payroll Import"](../codeunit/1676.md) (2 calls: `ImportGLTransactionsFromIIFFile → UploadFile`, `OnCreateSampleFile → BLOBExport`)
- [Codeunit 1916 "MigrationQB Mgt"](../codeunit/1916.md) (2 calls: `ImportQBData → ServerFileExists`, `ImportQBData → UploadFileWithFilter`)
- [Codeunit 1918 "MigrationQB Data Loader"](../codeunit/1918.md) (2 calls: `CleanupFiles → DeleteServerFile`, `CleanupFiles → ServerRemoveDirectory`)
- [Codeunit 6224 "XML DOM Management"](../codeunit/6224.md) (2 calls: `LoadXMLDocumentFromFile → IsAllowedPath`, `LoadXMLDocumentFromFileWithXmlReaderSettings → IsAllowedPath`)
- [Codeunit 8619 "Config. Pckg. Compression Mgt."](../codeunit/8619.md) (2 calls: `ProcessGZip → GetFileName`, `ProcessGZip → IsValidFileName`)
- [Codeunit 9025 "Small Business Report Catalog"](../codeunit/9025.md) (2 calls: `RunDetailTrialBalanceReport → Magicpath`, `RunDetailTrialBalanceReport → ServerTempFileName`)
- [Codeunit 9510 "Document Service Management"](../codeunit/9510.md) (2 calls: `GetSafeDocumentServiceFolderName → GetSafeFileName`, `OnUploadDocument → GetSafeFileName`)
- [Page 346 "Item Picture"](../page/346.md) (2 calls: `ImportFromDevice → DeleteServerFile`, `ImportFromDevice → UploadFile`)
- [Page 409 "Item Variant Picture"](../page/409.md) (2 calls: `ImportFromDevice → DeleteServerFile`, `ImportFromDevice → UploadFile`)
- [Page 9183 "Generic Chart Setup"](../page/9183.md) (2 calls: `ExportChartDefinition → BLOBExport`, `ImportChartDefinition → BLOBImport`)
- and 53 more: data/code/graph/29/calls.json

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC27

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "File Management")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
