Click here to Skip to main content
15,889,116 members
Home / Discussions / C#
   

C#

 
GeneralRe: Access to the path is denied Pin
Arunkumar.Koloth26-Jul-12 5:49
Arunkumar.Koloth26-Jul-12 5:49 
GeneralRe: Access to the path is denied Pin
Dave Kreskowiak26-Jul-12 6:51
mveDave Kreskowiak26-Jul-12 6:51 
GeneralRe: Access to the path is denied Pin
Arunkumar.Koloth26-Jul-12 17:51
Arunkumar.Koloth26-Jul-12 17:51 
GeneralRe: Access to the path is denied Pin
Arunkumar.Koloth27-Jul-12 1:24
Arunkumar.Koloth27-Jul-12 1:24 
GeneralRe: Access to the path is denied Pin
Dave Kreskowiak27-Jul-12 2:08
mveDave Kreskowiak27-Jul-12 2:08 
GeneralRe: Access to the path is denied Pin
ignrod27-Jul-12 1:52
ignrod27-Jul-12 1:52 
GeneralRe: Access to the path is denied Pin
Arunkumar.Koloth27-Jul-12 2:08
Arunkumar.Koloth27-Jul-12 2:08 
GeneralRe: Access to the path is denied Pin
ignrod27-Jul-12 2:36
ignrod27-Jul-12 2:36 
You can try something like this. I have modified your code slightly to place reading and writing inside the main loop. Also, I recommend having your streams inside a using block, it is simpler to write and safer if any exception is thrown.
Note: This code is untested!!
C#
public static void Download(String strURLFileandPath, String strFileSaveFileandPath)
{
    HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(strURLFileandPath);
    HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
    byte[] inBuf = new byte[100000];
    int bytesToRead = (int)inBuf.Length;
    int bytesRead;
    using (Stream str = ws.GetResponseStream())
    {
        using (FileStream fstr = new FileStream(strFileSaveFileandPath, FileMode.OpenOrCreate, FileAccess.Write))
        {
            try
            {
                while ((bytesRead = str.Read(inBuf, 0, bytesToRead)) > 0)
                {
                    fstr.Write(inBuf, 0, bytesRead);
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
        }
    }
}

QuestionProblems Running an Executable... Pin
glennPattonWork326-Jul-12 3:08
professionalglennPattonWork326-Jul-12 3:08 
AnswerRe: Problems Running an Executable... Pin
Eddy Vluggen26-Jul-12 3:34
professionalEddy Vluggen26-Jul-12 3:34 
GeneralRe: Problems Running an Executable... Pin
glennPattonWork326-Jul-12 3:42
professionalglennPattonWork326-Jul-12 3:42 
GeneralRe: Problems Running an Executable... Pin
Eddy Vluggen26-Jul-12 6:40
professionalEddy Vluggen26-Jul-12 6:40 
GeneralRe: Problems Running an Executable... Pin
glennPattonWork327-Jul-12 0:17
professionalglennPattonWork327-Jul-12 0:17 
Questioncancelling the dataGridview RowValidating event is not returning me to the grid so i can edit the empty cell Pin
Martin kipth26-Jul-12 1:39
Martin kipth26-Jul-12 1:39 
GeneralRe: cancelling the dataGridview RowValidating event is not returning me to the grid so i can edit the empty cell Pin
Senser2226-Jul-12 2:08
Senser2226-Jul-12 2:08 
AnswerRe: cancelling the dataGridview RowValidating event is not returning me to the grid so i can edit the empty cell Pin
Eddy Vluggen26-Jul-12 2:09
professionalEddy Vluggen26-Jul-12 2:09 
QuestionI want to write freehand text in picture box using USB Pen : in pen mode Pin
Shirkeay25-Jul-12 21:40
Shirkeay25-Jul-12 21:40 
AnswerRe: I want to write freehand text in picture box using USB Pen : in pen mode Pin
Richard MacCutchan25-Jul-12 22:29
mveRichard MacCutchan25-Jul-12 22:29 
GeneralRe: I want to write freehand text in picture box using USB Pen : in pen mode Pin
Shirkeay4-Sep-12 23:09
Shirkeay4-Sep-12 23:09 
GeneralRe: I want to write freehand text in picture box using USB Pen : in pen mode Pin
Richard MacCutchan4-Sep-12 23:26
mveRichard MacCutchan4-Sep-12 23:26 
QuestionCPU usage problem when sending udp packets Pin
asghari_mohsen25-Jul-12 10:29
asghari_mohsen25-Jul-12 10:29 
AnswerRe: CPU usage problem when sending udp packets Pin
Dave Kreskowiak25-Jul-12 10:44
mveDave Kreskowiak25-Jul-12 10:44 
GeneralRe: CPU usage problem when sending udp packets Pin
asghari_mohsen25-Jul-12 11:00
asghari_mohsen25-Jul-12 11:00 
QuestionCompare two files Pin
jojoba201125-Jul-12 2:15
jojoba201125-Jul-12 2:15 
AnswerRe: Compare two files Pin
Eddy Vluggen25-Jul-12 2:19
professionalEddy Vluggen25-Jul-12 2:19 

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.