function Export-File {
param (
[Parameter(Mandatory=$true)]
[string]$file_text,
[Parameter(Mandatory=$true)]
[string]$file_path,
[Parameter(Mandatory=$true)]
[string]$file_name,
[Parameter(Mandatory=$true)]
[string]$file_format
)
if (-not (Test-Path -Path $file_path -PathType Container)) {
Write-Error "The specified file path does not exist: $file_path"
return
}
try {
$full_path = Join-Path -Path $file_path -ChildPath "$file_name.$file_format"
$file_text | Out-File -FilePath $full_path -Force
Write-Host "File successfully exported to: $full_path"
}
catch {
Write-Error "An error occurred while exporting the file: $_"
}
}