Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to create an installer for Excel Plug In Pin
Eddy Vluggen5-Apr-10 23:15
professionalEddy Vluggen5-Apr-10 23:15 
GeneralRe: How to create an installer for Excel Plug In Pin
Ashish_Sood6-Apr-10 2:21
Ashish_Sood6-Apr-10 2:21 
GeneralRe: How to create an installer for Excel Plug In Pin
Eddy Vluggen6-Apr-10 3:01
professionalEddy Vluggen6-Apr-10 3:01 
QuestionHow to retrieve last application startup time Pin
Rikq5-Apr-10 22:17
Rikq5-Apr-10 22:17 
AnswerRe: How to retrieve last application startup time Pin
Mycroft Holmes5-Apr-10 22:36
professionalMycroft Holmes5-Apr-10 22:36 
AnswerRe: How to retrieve last application startup time Pin
Luc Pattyn6-Apr-10 2:30
sitebuilderLuc Pattyn6-Apr-10 2:30 
AnswerRe: How to retrieve last application startup time Pin
PIEBALDconsult6-Apr-10 4:37
mvePIEBALDconsult6-Apr-10 4:37 
QuestionError While Large File Uploading Pin
sjs4u5-Apr-10 21:08
sjs4u5-Apr-10 21:08 
Hi,

I am using webclient while uploading large file(135MB) using windows application. My Code works but when it reaches to stream.close() it showing following error

Error:-

The CLR has been unable to transition from COM context 0x1ff030 to
COM context 0x1ff1a0 for 60 seconds. The thread that owns the destination
context/apartment is most likely either doing a non pumping wait or processing
a very long running operation without pumping Windows messages. This situation
generally has a negative performance impact and may even lead to the application
becoming non responsive or memory usage accumulating continually over time.
To avoid this problem, all single threaded apartment (STA) threads should use
pumping wait primitives (such as CoWaitForMultipleHandles) and routinely
pump messages during long running operations.


So because of that my file is not uploaded. what is the problem?

My Code is:-




WebClient client = new WebClient();
Stream stream = client.OpenWrite(remoteFilename, "PUT");

// The buffer size is set to 2kb
const int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;

// Opens a file stream (System.IO.FileStream) to read the file
// to be uploaded
FileStream fs = fileInf.OpenRead();

int doneSoFar = 0;
// Read from the file stream 2kb at a time
contentLen = fs.Read(buff, 0, buffLength);
//added for accurate progress
doneSoFar += contentLen;
setItemStatus("Uploading");
while (contentLen != 0)
{
setItemProgress(doneSoFar, fileInf.Length);

// Write Content from the file stream to the FTP Upload Stream
stream.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
doneSoFar += contentLen;
}

// Close the file stream and the Request Stream
stream.Close();
fs.Close();



for Small file size it works fine.



Thanks
sjs
QuestionStore and retrieve list of structures Pin
Reza Shojaee5-Apr-10 19:44
Reza Shojaee5-Apr-10 19:44 
AnswerRe: Store and retrieve list of structures Pin
Eddy Vluggen5-Apr-10 22:13
professionalEddy Vluggen5-Apr-10 22:13 
Questionhow to get the row index value in datagridview Pin
crisjala5-Apr-10 17:27
crisjala5-Apr-10 17:27 
AnswerRe: how to get the row index value in datagridview Pin
Reza Shojaee5-Apr-10 20:00
Reza Shojaee5-Apr-10 20:00 
Questionpass an object by value. Pin
prasadbuddhika5-Apr-10 17:08
prasadbuddhika5-Apr-10 17:08 
AnswerRe: pass an object by value. Pin
PIEBALDconsult5-Apr-10 17:16
mvePIEBALDconsult5-Apr-10 17:16 
AnswerRe: pass an object by value. Pin
Luc Pattyn5-Apr-10 17:18
sitebuilderLuc Pattyn5-Apr-10 17:18 
GeneralRe: pass an object by value. Pin
prasadbuddhika5-Apr-10 17:49
prasadbuddhika5-Apr-10 17:49 
GeneralRe: pass an object by value. Pin
Praveen Raghuvanshi5-Apr-10 21:06
professionalPraveen Raghuvanshi5-Apr-10 21:06 
GeneralRe: pass an object by value. Pin
Dave Kreskowiak6-Apr-10 1:49
mveDave Kreskowiak6-Apr-10 1:49 
AnswerRe: pass an object by value. Pin
SBGTrading6-Apr-10 2:06
SBGTrading6-Apr-10 2:06 
GeneralRe: pass an object by value. Pin
PIEBALDconsult6-Apr-10 4:59
mvePIEBALDconsult6-Apr-10 4:59 
GeneralRe: pass an object by value. Pin
DaveyM696-Apr-10 10:41
professionalDaveyM696-Apr-10 10:41 
QuestionValidate Class Properties Pin
Kevin Marois5-Apr-10 15:41
professionalKevin Marois5-Apr-10 15:41 
AnswerRe: Validate Class Properties Pin
FyreWyrm5-Apr-10 15:51
FyreWyrm5-Apr-10 15:51 
GeneralRe: Validate Class Properties Pin
Kevin Marois5-Apr-10 15:52
professionalKevin Marois5-Apr-10 15:52 
AnswerRe: Validate Class Properties Pin
N a v a n e e t h5-Apr-10 15:59
N a v a n e e t h5-Apr-10 15:59 

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.