PDA

View Full Version : Supress path during file copy



pjhiggins
02-27-2004, 02:06 PM
Is it possible to supress the path in the status dialog box during a file copy?

During my copy operation the paths are so long that the status box ends up going beyond the screen border.

To ither remove it all together or have it show a percentage as the file is copied would be super.

Thanks!

Desmond
02-27-2004, 03:12 PM
Hello PjHiggins,

I would use a callback function to omit the path info:



--Copy Callback Function
function CopyCallBack (sSource, sDestination, nCopied, nTotal)
--Set the title
StatusDlg.SetTitle("Copy");

--Set the message
StatusDlg.SetMessage("Copying Files . . . Please Wait . . .");

--Get the path info
tCurrentFile = String.SplitPath(sSource);

--get just the file name and extension (omit drive/folder info)
sCurrentFile = tCurrentFile.Filename .. tCurrentFile.Extension;

--set the status text
StatusDlg.SetStatusText("Current File: " .. sCurrentFile .. "\r\nBytes Copied: " .. nCopied .. " / " .. nTotal);
end


--Show the status Dialog
StatusDlg.Show(0, false);

--Perform the copy action, using a callback function
File.Copy(Source, Destination, false, false, false, false, CopyCallBack);

--Hide the status Dialog
StatusDlg.Hide();


You can make the status dialog do whatever you want!

Hope that helps.

pjhiggins
02-27-2004, 03:40 PM
Thanks! Yes, that's what I was looking for.

Question...
I can't find sSource, sDestination, nCopied, nTotal in the documentation.

Where did they come from and is there a list of them all?

Thanka again!

Desmond
02-27-2004, 03:50 PM
Originally posted by pjhiggins
Thanks! Yes, that's what I was looking for.

Question...
I can't find sSource, sDestination, nCopied, nTotal in the documentation.

Where did they come from and is there a list of them all?

Thanka again!

Hey PJ,

Those variables are required for the callback function. The names I pulled out of my head. The docs for File.Copy (under the callback function section) say something like "the function must be able to accept the following variables", and then there is a table/list. That's where I found them. Sorry for the lack of accuracy with that quote, but i'm running from memory here!

Lemme know if you have any other questions.

Desmond.

pjhiggins
02-27-2004, 04:02 PM
Gah! I found them.

Right where you said and right where I skimmed over them a dozen times.

Thanks again. Most helpful, you are! (/wave Yoda)