Recent

Author Topic: Drop File and Moving Files  (Read 11479 times)

StaticStupid

  • New Member
  • *
  • Posts: 31
Drop File and Moving Files
« on: November 08, 2010, 05:33:56 pm »
Hi, i have a question: Is it possible to take the dropped file in my form and move/copy it to some directory?

(ex. I will drop some image file, and i want the same image to be copied or moved to X directory.)

-If i can ask for example too.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Drop File and Moving Files
« Reply #1 on: November 08, 2010, 05:40:04 pm »
Yes, you can set AllowDropfiles form's property to true and write code on the event OnDropFiles to do whatever you want.
« Last Edit: November 08, 2010, 05:47:56 pm by typo »

StaticStupid

  • New Member
  • *
  • Posts: 31
Re: Drop File and Moving Files
« Reply #2 on: November 08, 2010, 05:55:57 pm »
I am fine with AllowDropFiles, now can u write me a simple code, how to accept the dropped Files, and relocate in some folder, move or copy, don't mind me which one?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Drop File and Moving Files
« Reply #3 on: November 08, 2010, 06:04:12 pm »
My Help System is down and I could not help you to find the specifoc stuff to move files, sorry.

Code: [Select]
function CopyFile(
 
  const SrcFilename: String;
 
  const DestFilename: String
 
):Boolean;

function CopyFile(
 
  const SrcFilename: String;
 
  const DestFilename: String;
 
  PreserveTime: Boolean
 
):Boolean
 

« Last Edit: November 08, 2010, 06:07:53 pm by typo »

StaticStupid

  • New Member
  • *
  • Posts: 31
Re: Drop File and Moving Files
« Reply #4 on: November 08, 2010, 06:22:30 pm »
When you can or when your Help System is Up, write me new code and explain it a little bit, coz i am newbie, meanwhile i will try to understand this thing.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Drop File and Moving Files
« Reply #5 on: November 08, 2010, 06:34:49 pm »
Code: [Select]
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String
  );
begin
  if CopyFile(FileNames[0],  DestFilename) then
    ShowMessage(FileNames[0] + ' copied');
end;

Why every newbie want to handle files?
« Last Edit: November 08, 2010, 06:49:57 pm by typo »

StaticStupid

  • New Member
  • *
  • Posts: 31
Re: Drop File and Moving Files
« Reply #6 on: November 08, 2010, 07:16:06 pm »
Well i have some ideas which will help to access to file and folder much easier than manual windows allow me, so it does require file handling, maybe that's why + its good for upgrading my knowledge! ^^

Awesome dude, THANK YOU!
« Last Edit: November 08, 2010, 07:31:44 pm by StaticStupid »

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Drop File and Moving Files
« Reply #7 on: November 08, 2010, 10:21:51 pm »
Why every newbie want to handle files?

because it something you can feel, noone likes abstract exercises.

StaticStupid

  • New Member
  • *
  • Posts: 31
Re: Drop File and Moving Files
« Reply #8 on: November 10, 2010, 12:15:17 am »
Question: How to copy the file with his own name and his own file type, and how to copy multiply files?
I was searching, nothing found, so just to know i am giving effort i am not sitting with crossed arms.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Drop File and Moving Files
« Reply #9 on: November 10, 2010, 02:17:00 am »
Quote
How to copy the file with his own name and his own file type
Ask with InputBox or self created dialog, CopyFile's 2nd argument doesn't have to have the same name. About file type, I think you're talking about file extension. It's just a concept to ease the OS (not always) and user to identify the content. The content itself could be totally different.
Quote
how to copy multiply files?
Use loop ;)

 

TinyPortal © 2005-2018