Topic: Limit type of file to save in database

Is it possible to limit the types of files displayed (eg*.pdf, *.docx) when using the "Save file in database" control?

Re: Limit type of file to save in database

Hello davidsmyth

A piece of code to help you :

var
  saveDialog : tsavedialog;    // Save dialog variable
begin
  // Create the save dialog object - assign to our save dialog variable
  saveDialog := TSaveDialog.Create(self);

  // Give the dialog a title
  saveDialog.Title := 'Save your text or word file';

  // Set up the starting directory to be the current one
  saveDialog.InitialDir := GetCurrentDir;

  // Allow only .txt and .doc file types to be saved
  saveDialog.Filter := 'Text file|*.txt|Word file|*.doc';

  // Set the default extension
  saveDialog.DefaultExt := 'txt';

  // Select text files as the starting filter type
  saveDialog.FilterIndex := 1;

  // Display the open file dialog
  if saveDialog.Execute
  then ShowMessage('File : '+saveDialog.FileName)
  else ShowMessage('Save file was cancelled');

  // Free up the dialog
  saveDialog.Free;
end;

JB

Re: Limit type of file to save in database

Many thanks, I'll give this a try.

Re: Limit type of file to save in database

Hello davidsmyth

Of course you will have to adapt this code to the syntax specific to MVD.

But that shouldn't be difficult, it is written in Delphi and MVD is coded in Delphi itself

Good luck !

JB