Click here to Skip to main content
15,886,806 members
Home / Discussions / C#
   

C#

 
AnswerRe: HeaderFile vs Class Pin
Pete O'Hanlon20-May-10 4:23
mvePete O'Hanlon20-May-10 4:23 
GeneralRe: HeaderFile vs Class Pin
jashimu20-May-10 4:38
jashimu20-May-10 4:38 
GeneralRe: HeaderFile vs Class Pin
PIEBALDconsult20-May-10 6:15
mvePIEBALDconsult20-May-10 6:15 
AnswerRe: HeaderFile vs Class Pin
Luc Pattyn20-May-10 4:55
sitebuilderLuc Pattyn20-May-10 4:55 
GeneralRe: HeaderFile vs Class Pin
jashimu20-May-10 5:41
jashimu20-May-10 5:41 
GeneralRe: HeaderFile vs Class Pin
Luc Pattyn20-May-10 5:54
sitebuilderLuc Pattyn20-May-10 5:54 
QuestionAccessing network share with username & password from c# Pin
Suunil20-May-10 2:56
Suunil20-May-10 2:56 
QuestionUploading with WebClient Pin
Matt Cavanagh20-May-10 2:13
Matt Cavanagh20-May-10 2:13 
Hi. I have the code below which I am using to upload files to my ashx page. It works great, although I cant seem to find a proper way of getting how much it has transferred.

the calling code:
WebClient wc = new WebClient();
wc.OpenWriteCompleted += (s2, e2) =>
{
   PushData(e2.Result, offset);
   e2.Result.Close();
};
wc.OpenWriteAsync(ub.Uri);

the push data code
private void PushData(Stream output, long offset)
        {
            byte[] buffer = new byte[4096];
            int bytesRead;
            bytesRead = theFileStream.Read(buffer, 0, buffer.Length);
            if (bytesRead != 0)
            {
                output.Write(buffer, 0, bytesRead);
                
                totalBytesDone += bytesRead;
                FireUpdateEvent(bytesRead);
            }
        }

The above code is slightly different to my actual code, for brevity sake.
Now, I had presumed that when it gets to output.Write(buffer,0,bytesRead); that that was the point where it sent the actual data and it would lock up and only goto the next line once its finished writing that section. But it goes on to totalBytesDone += bytesRead; before its written anything to the server. I presume the reason is that its doing the writing in a seperate thread in the background(or im actually looking at the wrong section of code and it writes somewhere else) - but for my totalBytesDone code to work i WANT it to lock up until its finished sending(i can put this all in a seperate thread later).

Ive downloaded tons of examples for doing this and they either dont work properly with my ashx file handler(i cant change it) or they use a WebClient method that just reports on 50% progress.

Please help, this is urgent.
Thanks Smile | :)
Strive to be humble enough to take advice, and confident enough to do something about it.

Questiondatagrid view autocomplete Pin
NarendraSinghJTV20-May-10 2:00
NarendraSinghJTV20-May-10 2:00 
QuestionC# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
willempipi20-May-10 0:28
willempipi20-May-10 0:28 
AnswerRe: C# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
Henry Minute20-May-10 1:55
Henry Minute20-May-10 1:55 
GeneralRe: C# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
willempipi20-May-10 2:04
willempipi20-May-10 2:04 
GeneralRe: C# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
Henry Minute20-May-10 2:07
Henry Minute20-May-10 2:07 
GeneralRe: C# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
willempipi20-May-10 2:18
willempipi20-May-10 2:18 
GeneralRe: C# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
Luc Pattyn20-May-10 2:47
sitebuilderLuc Pattyn20-May-10 2:47 
GeneralRe: C# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
willempipi20-May-10 3:25
willempipi20-May-10 3:25 
GeneralRe: C# Forms: Capture scroll event in a usercontrol with only static checkboxes. Pin
Luc Pattyn20-May-10 3:30
sitebuilderLuc Pattyn20-May-10 3:30 
QuestionVSS and Visual studio Pin
Zeyad Jalil20-May-10 0:25
professionalZeyad Jalil20-May-10 0:25 
AnswerYou have a habit of asking none C# questions in this forum. Would you please not do that? Pin
Pete O'Hanlon20-May-10 0:42
mvePete O'Hanlon20-May-10 0:42 
QuestionHow to create Contact form with C# in ASP.NET Pin
BasPoldervaart19-May-10 23:15
BasPoldervaart19-May-10 23:15 
AnswerRe: How to create Contact form with C# in ASP.NET Pin
Arun Jacob19-May-10 23:31
Arun Jacob19-May-10 23:31 
Questiondecimal question Pin
Jassim Rahma19-May-10 23:14
Jassim Rahma19-May-10 23:14 
AnswerRe: decimal question Pin
OriginalGriff20-May-10 1:17
mveOriginalGriff20-May-10 1:17 
AnswerRe: decimal question Pin
Heinzzy20-May-10 1:59
Heinzzy20-May-10 1:59 
AnswerRe: decimal question Pin
Luc Pattyn20-May-10 2:51
sitebuilderLuc Pattyn20-May-10 2:51 

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.