Click here to Skip to main content
15,915,848 members
Home / Discussions / C#
   

C#

 
GeneralRe: Arraylist between classes Pin
J4amieC17-Jan-07 22:08
J4amieC17-Jan-07 22:08 
Questionpost build event to create a directory Pin
Praveen Raghuvanshi17-Jan-07 19:08
professionalPraveen Raghuvanshi17-Jan-07 19:08 
AnswerRe: post build event to create a directory Pin
Stefan Troschuetz17-Jan-07 21:22
Stefan Troschuetz17-Jan-07 21:22 
QuestionHow to remove a method from CollectionBase Pin
Radgar17-Jan-07 19:02
Radgar17-Jan-07 19:02 
AnswerRe: How to remove a method from CollectionBase Pin
Guffa17-Jan-07 19:49
Guffa17-Jan-07 19:49 
AnswerRe: How to remove a method from CollectionBase Pin
Phillip M. Hoff17-Jan-07 19:57
Phillip M. Hoff17-Jan-07 19:57 
GeneralRe: How to remove a method from CollectionBase Pin
Radgar17-Jan-07 20:58
Radgar17-Jan-07 20:58 
QuestionWebclient/Webrequest Problem Pin
Planker17-Jan-07 18:45
Planker17-Jan-07 18:45 
My problem is in this line of code: strResponse = wcDownload.OpenRead(UpdateUrl);
the variable strResponse receives a null value, and blows up.

I know I am going to need to figure out how to handle this exception, I know the url i am trying to access works because earlier in the code i check the modified date with today's date and it calls this method.

Here is my download method

private void Download()
{


using (WebClient wcDownload = new WebClient())
{
try
{
// Create a request to the file we are downloading
webRequest = (HttpWebRequest)WebRequest.Create(UpdateUrl);
// Set default authentication for retrieving the file
webRequest.Credentials = CredentialCache.DefaultCredentials;
// Retrieve the response from the server
webResponse = (HttpWebResponse)webRequest.GetResponse();
// Ask the server for the file size and store it
Int64 fileSize = webResponse.ContentLength;

// Open the URL for download
strResponse = wcDownload.OpenRead(UpdateUrl);
// Create a new file stream where we will be saving the data (local drive)
strLocal = new FileStream(FilePath, 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);
// Invoke the method that updates the form's label and progress bar
this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { strLocal.Length, fileSize });
}
}
finally
{
// When the above code has ended, close the streams
strResponse.Close();
strLocal.Close();
UpdateFlag = false;
}
}
QuestionIntegrating Windows operating system with c# Pin
yashpunind17-Jan-07 18:27
yashpunind17-Jan-07 18:27 
AnswerRe: Integrating Windows operating system with c# Pin
Christian Graus17-Jan-07 20:07
protectorChristian Graus17-Jan-07 20:07 
QuestionAbout abstract class Pin
Ravi Shankar4317-Jan-07 18:14
Ravi Shankar4317-Jan-07 18:14 
AnswerRe: About abstract class Pin
Vinay Dornala17-Jan-07 18:55
Vinay Dornala17-Jan-07 18:55 
GeneralRe: About abstract class Pin
Ravi Shankar4317-Jan-07 19:02
Ravi Shankar4317-Jan-07 19:02 
Questionabout Abstract and Interface concept n C# Pin
Vinay Dornala17-Jan-07 18:03
Vinay Dornala17-Jan-07 18:03 
AnswerRe: about Abstract and Interface concept n C# Pin
jdkulkarni17-Jan-07 19:16
jdkulkarni17-Jan-07 19:16 
QuestionMoving Multiple Controls at runtime Pin
ArjunMunda17-Jan-07 17:26
ArjunMunda17-Jan-07 17:26 
QuestionDynamically creating objects using reflection Pin
mcd242417-Jan-07 17:01
mcd242417-Jan-07 17:01 
AnswerRe: Dynamically creating objects using reflection Pin
Phillip M. Hoff17-Jan-07 17:15
Phillip M. Hoff17-Jan-07 17:15 
GeneralRe: Dynamically creating objects using reflection Pin
mcd242417-Jan-07 17:22
mcd242417-Jan-07 17:22 
GeneralRe: Dynamically creating objects using reflection Pin
Phillip M. Hoff17-Jan-07 17:37
Phillip M. Hoff17-Jan-07 17:37 
GeneralRe: Dynamically creating objects using reflection Pin
mcd242417-Jan-07 18:07
mcd242417-Jan-07 18:07 
GeneralRe: Dynamically creating objects using reflection Pin
Phillip M. Hoff17-Jan-07 19:17
Phillip M. Hoff17-Jan-07 19:17 
GeneralRe: Dynamically creating objects using reflection Pin
Russell Jones17-Jan-07 23:00
Russell Jones17-Jan-07 23:00 
QuestionC# Dial-up manager Pin
oren201017-Jan-07 15:49
oren201017-Jan-07 15:49 
Questionget folder content form a webservice Pin
gcorgnet17-Jan-07 15:40
gcorgnet17-Jan-07 15:40 

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.