473,480 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem in Uploading the huge file to FTP using C#

29 New Member
Hi folks,
i am working in C# , i have problem while uploading the file to FTP which has size around 4MB.

The code which comes after the bold area is not executed.. here am interacting with DB for every succeessful upload. But its working well for the file which has small size around 1MB. Please give me a solution asap... My code is as follows.

Expand|Select|Wrap|Line Numbers
  1. string ftpServerIP = rowClient[1].ToString();
  2.       string ftpUserID = rowClient[2].ToString();
  3.       string Password = rowClient[3].ToString();
  4.  
  5.         //////// ---UpLoading...
  6.       FileInfo fileInf = new FileInfo(strfileLocation);
  7.  
  8.      string uri = ftpServerIP + "/" + fileInf.Name;
  9.  
  10.         // Get the object used to communicate with the server.
  11.       FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri);
  12.       request.Method = WebRequestMethods.Ftp.UploadFile;
  13.       request.Timeout = 3600000; // Equvalent to 1 Hour.
  14.  
  15.         // This example assumes the FTP site uses anonymous logon.
  16.        request.Credentials = new NetworkCredential(ftpUserID, Password);
  17.  
  18.       // Copy the contents of the file to the request stream.
  19.           StreamReader sourceStream = new StreamReader(fileInf.OpenRead());
  20.           byte[] fileContents =   Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
  21.            sourceStream.Close();
  22.            request.ContentLength = fileContents.Length;
  23.            Stream requestStream = request.GetRequestStream();
  24.            requestStream.Write(fileContents, 0, fileContents.Length);
  25.  
  26.       requestStream.Close();
  27.  
  28.            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
  29.  
  30.              Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
  31.  
  32.       response.Close();
  33.  
  34.       updateDB(rowClient[0].ToString(), dtime.ToString());
  35.  
  36.       ExecuteNonQuery("update callInfo set status = 'T' where clientId='" + rowClient[0].ToString().Trim() + "' and status ='Q' and date between '" + LastBackUpTime + "' and '" + dtime.ToString() + "'");
Jan 16 '08 #1
3 2599
kenobewan
4,871 Recognized Expert Specialist
Suggests your design has reached its performance level, may be time to try a new method...
Jan 16 '08 #2
Bremanand
29 New Member
Hi thanks for your reply... i have very less code here... i hope this wouldnt be a performance issue... is anything related to Timeout??? i tried request.Timeout , requeststream.ReadTimeout,requeststream.writeTimeo ut.
it doesnt help me... plz find me a solution.

Regards,
Bremanand.S
Jan 17 '08 #3
Bremanand
29 New Member
Hi there,

Can anyone please solve this problem?????
Jan 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
17464
by: ok | last post by:
Hello, Q: How do I get image width and height before uploading an image? This because, I want to restrict people uploading huge files. Thanks in advance
9
2362
by: R. Rajesh Jeba Anbiah | last post by:
Q: How should I handle file upload? A: File uploading requires HTML form of content type "multipart/form-data". The file content has to be POSTed/submitted via the form and once the file is...
3
1862
by: Mike | last post by:
Hi i have a problem in asp.ne i am uploading file to the server using htmlinput controls and every thing is o but i try to upload larger file to the server like more than 4 mb and about 10mb i got...
10
1776
by: Mario Rodriguez | last post by:
HI people, there is an alternative way to upload files than the ASP.NET native way? Is OK for small files but It doesn't seems to be convenient for an application where there is a lot of paralell...
1
2183
by: Jonathan | last post by:
Hi everyone, I have a problem with the file uploading in Asp.Net and I have read a lot on forums on this but never found an answer. Here is the problem: I know Asp.Net maximum Length for...
13
4280
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
3
1377
by: detrox | last post by:
Hi, all I have two questions about uploading files using php & html: 1. How can i add a `file type' in the pop window when i click `browse' button of the `<input type=file>'. 2. How can i get...
4
1815
by: ish | last post by:
hello everybody...... plz help me out... how we can store the acual path of uploading file.i want to store the path of file in my database...bt i m not getting anyway to implement that......if...
3
5153
by: muziburrehaman | last post by:
i am looking for code in php to upload the 1 gb files. any one can please help me by sending the code....
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7022
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4501
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3013
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.