R
Rich P
In my custom ftp app that I am writing for downloading my own .jpg and
.mp4 files from my ftp server I have implemented a backgroundworker
control where the downloading takes place and a progressbar control for
monitoring the progress. I am having a problem with .mp4 files larger
than 20 megs (sometimes larger than 23 megs). I pass the int value of
the Convert.ToInt32(fileBytesRead * 100 / fileSize); value to the
ProgressChanged event and for the .mp4 files larger than 20 megs I get
the following message around 75%. Below is the code I use to perform
the download:
...
75
75
75
75
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
75
75
75
75
-75
-75
-75
-75
...
//this code works fine for files under 20megs in size
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ftpServer +
"/" + fileName);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false; //close the connection when done
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
int fileBytesRead = 0;
int fileSize = Convert.ToInt32(fileSize);
int n;
byte[] buffer = new byte[4096];
using (Stream streamFile = File.Create(s1[0] + "\\" + fileName))
{
int bytesRead;
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
streamFile.Write(buffer, 0, bytesRead);
fileBytesRead += bytesRead;
n = Convert.ToInt32(fileBytesRead * 100 / fileSize);
backgroundWorker2.ReportProgress(n, "in use");
}
}
stream.Close();
Any suggestions appreciated what I need to change to accommodate .mp4
files larger than 20-23 megs.
Thanks
Rich
.mp4 files from my ftp server I have implemented a backgroundworker
control where the downloading takes place and a progressbar control for
monitoring the progress. I am having a problem with .mp4 files larger
than 20 megs (sometimes larger than 23 megs). I pass the int value of
the Convert.ToInt32(fileBytesRead * 100 / fileSize); value to the
ProgressChanged event and for the .mp4 files larger than 20 megs I get
the following message around 75%. Below is the code I use to perform
the download:
...
75
75
75
75
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
75
75
75
75
-75
-75
-75
-75
...
//this code works fine for files under 20megs in size
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ftpServer +
"/" + fileName);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false; //close the connection when done
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
int fileBytesRead = 0;
int fileSize = Convert.ToInt32(fileSize);
int n;
byte[] buffer = new byte[4096];
using (Stream streamFile = File.Create(s1[0] + "\\" + fileName))
{
int bytesRead;
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
streamFile.Write(buffer, 0, bytesRead);
fileBytesRead += bytesRead;
n = Convert.ToInt32(fileBytesRead * 100 / fileSize);
backgroundWorker2.ReportProgress(n, "in use");
}
}
stream.Close();
Any suggestions appreciated what I need to change to accommodate .mp4
files larger than 20-23 megs.
Thanks
Rich