![]() |
problems with CopyFileEX
This is my first time trying to copy a file using code. I am having trouble getting the function call correct. Could someone please look at what I am doing wrong?
:
This is on a Win XP Pro SP2 box using Dev-C++ 4.9.9.2 Thanks, -BB98 |
Re: problems with CopyFileEX
Take out the types. I can't even compile with them in there. The function has already been written in windows.h, just call it. For example:
:
CopyFileEx("C:\\Dev-Cpp\\1.txt", "C:\\2.txt", NULL, NULL, false, COPY_FILE_FAIL_IF_EXISTS | COPY_FILE_RESTARTABLE);Works fine for me to copy and paste on a local computer. Dev-C++ 4.9.9.2 here as well. |
Re: problems with CopyFileEX
Thanks for the reply. I included the types in my post to try and be as clear as I could in the post. I did not have the types in my function though I did have a typo I found.
On another note, I am trying to use the CopyProgressRoutine CALLBACK. As usual, I am in in a bit over my head. I haven't a clue where to start to get it working. Do I have to declare and define the function in my code? I have visited MSDN, but feel like an idiot because I cannot make heads or tails of what its telling me :confused: Does anyone know of a tutorial or other guide to help me understand its use? thanks, -BB98 |
Re: problems with CopyFileEX
You have to write your own CopyProgressRoutine. You need to define it as specified:
Quote:
|
Re: problems with CopyFileEX
Its been a while since I have been able to work on this program, but have got back into it yesterday. I have the copy and callback functions working, I am having trouble calculating the percentage of the file that's being copied however. I am using that data to increment a progressbar. Through some research it appears that the problem is with the LARGE_INTEGER type.
Does anyone have any documentation (or links) on how to use math functions with that type? I was hoping it was going to be as easy as :
It obviously isn't since I get the error :
Thank you for your help thus far :) |
Re: problems with CopyFileEX
LARGE_INTEGER maybe doesn't define operator/(const LARGE_INTEGER)?
|
Re: problems with CopyFileEX
anyone have a clue what's going on with this?
Thanks |
Re: problems with CopyFileEX
LARGE_INTEGER is a union type. You have to access it's data members which are actually numeric types.
example: :
LARGE_INTEGER x, y;http://msdn2.microsoft.com/en-us/lib...13(VS.85).aspx |
Re: problems with CopyFileEX
Thanks Cache, that works though I am still having problems with it working for some reason.
I have resorted to setting individual variables equal to each part and number that is included in the math portion of figuring the amount of the file that has been copied. I have set TotalFileSize.QuadPart equal to Total and TotalBytesTransfered.QuadPart equal to Transfer. If I look at either of these values at each call to the progress routine, Total is the correct size of the file and Transfer is increasing in size appropriately until it is equal to Total when the copy function ends. I have a few other variables: Divide, Percent, & Hundred. Divide is a float, Percent is an int and Hundred is an int whose value is 100. This is the bit of math I have in my CALLBACK_CHUNK_FINISHED: :
I have also tried: :
Percent = ((Transfer / Total)*(Hundred));With either method, at any step in the progress Divide is zero and Percent is zero in which Total and Transfer are their correct values. The only time Percent is not zero is when the process is complete and Transfer and Total are equal. Obviously Percent then equals 100 and the progress bar is stepped to the end. This makes no sense to me at all. Anyone know something else I can try, or am I overlooking something simple again? Thanks, ~BB98 |
Re: problems with CopyFileEX
My guess (and it is a guess) is that Total and Transfer are ints (or some variant like that) and when you divide one by the other the result is an int (even if you put it into a float, it's doing integer division)
Try it, I wrote a quick program that did int a = 5; int b = 6; float c = a/b; Result is 0 because a and b are ints. have to do c = (float)a/(float)b (or something like that, I'm using C# so syntax may be slightly different). |
| All times are GMT -5. The time now is 3:36 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC