Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

i am new at .net framework please help me to solve my issue

I am working with windows form with .net 2.0

while uploading less than 2MB file using 'web client' 'upload file' method it works file but uploading more than 2MB file it through exception Unable to write data to the transport connection: an existing connection was forcibly closed by remote host
i have read lots of forum but not works for my problem

I have iis5.1 for uploading file
this all i am doing on my local machine.

This is my code to upload file

C#
private bool CreateNetcomFile(string ServerAddress, string docUniqueString)
        {
            string docName = path + "\\" + txtDocumentName.Text + "_" + docUniqueString;
            ZipInfo zip = new ZipInfo(path + "\\" + txtDocumentName.Text + ".zip");
            zip.PackFiles(null, objFiles, null);
            if (System.IO.File.Exists(zip.FullName))
            {
                System.IO.FileInfo objFile = new System.IO.FileInfo(zip.FullName);
                objFile.MoveTo(docName + ".netcom");
                System.Net.WebClient client = new System.Net.WebClient();

             try
              {
                 client.UploadFile(ServerAddress, "POST", docName + ".netcom");                  
              }
              catch (Exception ex)
             {
               MessageBox.Show(ex.Message);
             }
          }
        }


Thanks in advance every suggestion is appreciated.
Posted
Updated 3-Jun-14 20:48pm
v3

1 solution

Add in your config.sys file in section
HTML
<system.web></system.web>

HTML
<httpruntime maxrequestlength="150000" />

You can upload then files uptill 150Mb
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900