SharePoint Copy Webservice

Dammit it seems to be working with s around smaller files (>1gb) but nothing bigger as then it will go up to 99% and an error would occur. Will play around with it.. :(
 
Dammit it seems to be working with s around smaller files (>1gb) but nothing bigger as then it will go up to 99% and an error would occur. Will play around with it.. :(

You're probably going to have to change your byte counters from int to long, as anything bigger that 2GB will cause int to exceed it's limit of 2,147,483,647. Dunno if that's maybe what's causing your issue.
 
Your right!!! But it seems the issue is the progressbar.Maximum property is an integer so any value that I set as the max has to be in the integer range.. This is going to take so thought
 
Your right!!! But it seems the issue is the progressbar.Maximum property is an integer so any value that I set as the max has to be in the integer range.. This is going to take so thought

Not really, just divide "fileLen" by 1048576 when setting it as the progress bar's maximum and do the same with "totalBytesRead" when setting it as its value. That way your progress bar will effectively work on the amount of MB copied and not just bytes. Will give you the same result in the end.
 
Ok tihs is what I did
Code:
int fileLen = Convert.ToInt32((ulong)(sourceFile.Length)/1048576);  
progBar.Maximum = fileLen;
then
Code:
int pro = ((int)totalBytesRead / 1048576);
progBar.Value = pro;
From that I get this error on the progBar.Value : Value of '-2048' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Using a 2.4Gb file. FileLen is 2236. Thoughts? Going to play around with this in the interim.
 
Ok tihs is what I did
Code:
int fileLen = Convert.ToInt32((ulong)(sourceFile.Length)/1048576);  
progBar.Maximum = fileLen;
then
Code:
int pro = ((int)totalBytesRead / 1048576);
progBar.Value = pro;
From that I get this error on the progBar.Value : Value of '-2048' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Using a 2.4Gb file. FileLen is 2236. Thoughts? Going to play around with this in the interim.

Try changing "int pro = ((int)totalBytesRead / 1048576);" to "int pro = (int)(totalBytesRead / 1048576);".

Currently it will probably attempt to convert totalBytesRead to int before deviding, which will not work correctly if totalBytesRead is already over the maximum value of int.
 
You can always use your formula for the max as well, as in int pro = Convert.ToInt32((ulong)(totalBytesRead)/1048576).

The fact that you're converting to ulong means it won't give you a negative number under any circumstance.
 
:o lol I really do have alot to learn :) Thanks again Frikkenator. All done and working perfectly now :)
 
Top
Sign up to the MyBroadband newsletter
X