Topic: How To Properly Use 'CopyTo"

Hello,

I created three File Databases.
By default the folders are linked to the same folder you choose.

I don't want this...

What I want is for the File Database to have it's own perspective folder and any that I choose.

I used went by the instruction..
but couldn't seem to even make that work.

What am I doing wrong here?

I used:
\
c:\files\
files

Post's attachments

Attachment icon filedatabase.png 203.38 kb, 290 downloads since 2015-08-28 

Re: How To Properly Use 'CopyTo"

Hello heribertom6466

When creating a database, it is not advisable to store images (or anything else) in the same base (weight too heavy, difficult and time manipulation).
Here is the goal of property CopyTo.

Let's take an example :

You want create an application to manage yours books. You want to display the book cover.
In this purpose, you place a DBImage component.

2 options :

1 - You store pictures inside your database. Bad choice. Forget it :
2 - You want store pictures in folders apart. Good option.

DBImage component has two properties to use :

- StoreFile (for the bad solution)
- LinkFile : Choose this option to say MVD to store pictures not inside database but in a folder apart.

The other property is CopyTo. Here you get name of the folder storing pictures (i.e. \Covers).
Then all pictures will be saved in this folder which lighten the weight of the base.

You can even narrow down your choice of records.
Let's say in our example of management books you want to create a folder by author and not a catchall folder
(i.e : \COBEN, \RANKIN,\KING and so  on...).

If the form you enter yours books has a combobox for the name of the auteur, you can add

in event OnAfterClick of your button Save this instruction

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
       Form1.DBImage1.dbCopyTo := '\Covers\' + Form1.ComboBox1.Text ;     // We create a subfolder in the folder  Covers
end;

it works perfectly, I did it for my own management of my books.

It is these small features that make a great MVD database management software.

If you need any explanation, please write us

JB

Re: How To Properly Use 'CopyTo"

JB,

Awesome!
Great deal of detailed information
So this explains why my files weren't being linked to it's perspective folder.
ahhh makes sense...

Back to my database...

Thank you,
Eddie

Re: How To Properly Use 'CopyTo"

JB,

It worked finally after 50 tries of trial and error. :-)
There was an error on my part. fixed.

Did as you said and it works great!

Thank you,
Eddie

Re: How To Properly Use 'CopyTo"

I do not totally agree with jean.brezhonek about storing files in database.

If the files are by far too big, it is obviously a bad idea to store files in DB, however storing small files makes it easier to distribute an application and to make backups as everything is at the same place.

As an extreme example I would take the situation where a curious people delete any or all file(s)stored in a folder but linked in your db by mistake and your application is up side down.
I have seen so many corporate applications of this kind and it is always a nightmare when it comes to backups and permissions and broken links...


It is on you to decide about the best solution for your application.

Re: How To Properly Use 'CopyTo"

jean.brezhonek and tcoton
Thank you for the help! )

Dmitry.

Re: How To Properly Use 'CopyTo"

Hello Dmitry

It is you that we must thank.
I did that taking advantage of your different aids.
It is thanks to you if I am comfortable with MVD


Hello tcoton :

In principle you are right..
It all depends on the priority that we want to give to its application.
It will always be an exciting debate

Best regards

JB

Re: How To Properly Use 'CopyTo"

Hello jean.brezhonek, nice tip thanks,

can we do this with files instead of images?

for example, can i create a folder by script to store a pdf file for example like you did on your image example?

Re: How To Properly Use 'CopyTo"

Montenegr0
There is no different, you can do the same using component DBFile.

Dmitry.

Re: How To Properly Use 'CopyTo"

and what about if i have a report button that  when i click on it will open a PDF file filled with the information i write in the database program and create a OnClick procedure to this button to after i click the button and opens the PDF stores it to a \Pdf_reports folder?

can anyone help me with this?

Re: How To Properly Use 'CopyTo"

Montenegr0

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    OpenFile(ExtractFileDir(Application.ExeName)+'\Pdf_reports');
end;
Dmitry.

Re: How To Properly Use 'CopyTo"

Thank you sooo much smile

If i have a DBfile with option to open file can i do what you said in the last post and copy the destination of that file to this dbfile? For open it with the program? Will be like this?


procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    OpenFile(ExtractFileDir(Application.ExeName)+'\Pdf_reports');
Form1.DBFile1.Text :='\Pdf_reports';
end;

Re: How To Properly Use 'CopyTo"

when i try to use the script you give it sais that ExtractFileDir is a undeclared identifier sad

Re: How To Properly Use 'CopyTo"

Dmitry can you help me why is giving me this error?

Re: How To Properly Use 'CopyTo"

Montenegr0
I think you use old version, just download latest version.

Dmitry.