Click here to Skip to main content
15,893,564 members
Home / Discussions / C#
   

C#

 
AnswerRe: Continuous button? Pin
Christian Graus4-Oct-07 2:26
protectorChristian Graus4-Oct-07 2:26 
GeneralRe: Continuous button? Pin
hostopolis4-Oct-07 2:33
hostopolis4-Oct-07 2:33 
GeneralRe: Continuous button? Pin
Kristian Sixhøj4-Oct-07 5:31
Kristian Sixhøj4-Oct-07 5:31 
GeneralRe: Continuous button? Pin
hostopolis4-Oct-07 5:38
hostopolis4-Oct-07 5:38 
GeneralRe: Continuous button? Pin
Kristian Sixhøj4-Oct-07 5:57
Kristian Sixhøj4-Oct-07 5:57 
GeneralRe: Continuous button? Pin
Andrew Rissing4-Oct-07 6:06
Andrew Rissing4-Oct-07 6:06 
GeneralRe: Continuous button? Pin
hostopolis4-Oct-07 6:38
hostopolis4-Oct-07 6:38 
QuestionWEBcLIENT pROBLEM Pin
t4ure4n4-Oct-07 2:11
t4ure4n4-Oct-07 2:11 
Hello Every 1.
I have a strange problem with webclient. I have the following method in a class created to download files from a website. I download files sequentially i.e download one file dispose the download class object then create a new object and call the download method and so on....
public void DownloadVideo()
        {          
            try
            {
                ///The WebClient object that will download the file
                WebClient wcDownload = new WebClient();
                // Create a request to the file we are downloading
                webRequest = (HttpWebRequest)WebRequest.Create(_VideoUrl);
                // Set default authentication for retrieving the file
                webRequest.Credentials = CredentialCache.DefaultCredentials;
                // Retrieve the response from the server
                webResponse = (HttpWebResponse)webRequest.GetResponse();
                //check if the webresponse is ok
                if (webResponse.ResponseUri.ToString() != "http://www.xyz.com/error.htm")
                {
                    // Ask the server for the file size and store it
                    Int64 fileSize = webResponse.ContentLength;
                    // Open the URL for download             
                    strResponse = wcDownload.OpenRead(_VideoUrl);
                    // Create a new local file stream 
                    strLocal = new FileStream(_VideoPath, FileMode.Create, FileAccess.Write, FileShare.None);
                    // It will store the current number of bytes we retrieved from the server
                    int bytesSize = 0;
                    // A buffer for storing and writing the data retrieved from the server
                    byte[] downBuffer = new byte[2048];
                    // Loop through the buffer until the buffer is empty
                    while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
                    {
                        // Write the data from the buffer to the local hard drive
                        strLocal.Write(downBuffer, 0, bytesSize);
                        UpdateVideoProgressEventArgs uvpea = new UpdateVideoProgressEventArgs(strLocal.Length, fileSize);
                        UpdateVideoProgressEvent(this, uvpea);
                    }
                }//end of second if
            }//end of try
            catch (Exception exp)
            {
                MessageBox.Show("Error in startDownload due to : " + exp.Message);
            }
            finally
            {
                // When the above code has ended, close the streams                             
                if (strLocal != null)
                    strLocal.Close();

                if (strResponse != null)
                    strResponse.Close();
                webRequest = null;
                webResponse = null;
            }
        }//end of method

It works fine for the first file download but fails for the second file because it just hangs up @
strResponse = wcDownload.OpenRead(_VideoUrl);

and eventually time out.

o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

QuestionData Grid Item Index ------------- Help Pin
dsaikrishna4-Oct-07 1:40
dsaikrishna4-Oct-07 1:40 
JokeRe: Data Grid Item Index ------------- Help Pin
karthick.n.mca4-Oct-07 1:49
karthick.n.mca4-Oct-07 1:49 
GeneralRe: Data Grid Item Index ------------- Help Pin
karthick.n.mca4-Oct-07 1:51
karthick.n.mca4-Oct-07 1:51 
AnswerRe: Data Grid Item Index ------------- Help Pin
dsaikrishna4-Oct-07 1:51
dsaikrishna4-Oct-07 1:51 
GeneralRe: Data Grid Item Index ------------- Help Pin
karthick.n.mca4-Oct-07 1:53
karthick.n.mca4-Oct-07 1:53 
QuestionBest method to Edit CSV file at run time Pin
Kannan Ramasamy4-Oct-07 1:00
Kannan Ramasamy4-Oct-07 1:00 
AnswerRe: Best method to Edit CSV file at run time Pin
Christian Graus4-Oct-07 2:30
protectorChristian Graus4-Oct-07 2:30 
Question[Message Deleted] Pin
Fathi Gasir4-Oct-07 0:55
Fathi Gasir4-Oct-07 0:55 
AnswerRe: CHAID Algorithm Pin
Christian Graus4-Oct-07 0:59
protectorChristian Graus4-Oct-07 0:59 
AnswerRe: CHAID Algorithm Pin
Pete O'Hanlon4-Oct-07 1:37
mvePete O'Hanlon4-Oct-07 1:37 
QuestionCheck AD rights Pin
robot_rock4-Oct-07 0:44
robot_rock4-Oct-07 0:44 
Questionto validate date on datagrid template plz help............. Pin
P_Elza4-Oct-07 0:43
P_Elza4-Oct-07 0:43 
AnswerRe: to validate date on datagrid template plz help............. Pin
Christian Graus4-Oct-07 0:56
protectorChristian Graus4-Oct-07 0:56 
Questionchange network settings using C# Pin
VirtualVoid.NET4-Oct-07 0:01
VirtualVoid.NET4-Oct-07 0:01 
QuestionCursors on form? Pin
stevenykl3-Oct-07 23:52
stevenykl3-Oct-07 23:52 
AnswerRe: Cursors on form? Pin
Christian Graus4-Oct-07 0:05
protectorChristian Graus4-Oct-07 0:05 
AnswerRe: Cursors on form? Pin
VirtualVoid.NET4-Oct-07 0:06
VirtualVoid.NET4-Oct-07 0:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.