What am i unable to achieve is sending that file to a specific folder. Instead, it downloads to the downloads- any suggestions?
action(UploadtoLocalDisk)
{
ApplicationArea = All;
Caption = 'Upload to Local Disk';
trigger OnAction()
var
InStream: InStream;
FileName: Text;
FilePath: Text;
RecRef: RecordRef;
LocalFileAttachment: Record "Local File Attachment";
TempBlob: Codeunit "Temp Blob";
OutStream: OutStream;
FileManagement: Codeunit "File Management";
FromFilter: Text;
NameofFile: Text;
begin
//specifies the types of files that can be uploaded. The pattern 'All Files (*.*)|*.*' allows all file types.
FromFilter := 'All Files (*.*)|*.*';
//opens dialogue if upload is sucessful, returns a file available instream
if UploadIntoStream('Select a file', '', FromFilter, FileName, InStream) then begin
//store file name
NameofFile := FileName + Format(CreateGUID()) + NameofFile + '.pdf';
FilePath := 'D:\Bcdocs';
TempBlob.CreateOutStream(OutStream);
CopyStream(OutStream, InStream);
// FileManagement.BLOBExport(TempBlob, NameofFile, true);
DownloadFromStream(InStream, '', FilePath, '', NameofFile);
RecRef.GetTable(Rec);
LocalFileAttachment.Init();
LocalFileAttachment."File Path" := FilePath;
LocalFileAttachment."Record ID" := RecRef.RecordId();
LocalFileAttachment.Insert();
end;
end;
}