473,378 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Problem with ftp web request

42
hi all,

i'm trying to develop a file uploader, it uses ftp, language is c# the application is c#windows app
the main part of code that i use is as below

Expand|Select|Wrap|Line Numbers
  1. try
  2.             {
  3. FtpWebRequest request; 
  4.             request = getFTPRequestObject(strNewFile);
  5.                 request.ContentLength = fileInfo.Length;
  6.  
  7. requestStream = request.GetRequestStream();
  8.  
  9.                 FileStream fileStream = fileInfo.OpenRead();
  10.                 contentLen = fileStream.Read(buffer, 0, buffLength);
  11.  
  12.                 while (contentLen != 0)
  13.                 {
  14.                     requestStream.Write(buffer, 0, contentLen);
  15.                     contentLen = fileStream.Read(buffer, 0, buffLength);
  16.  
  17.                 }
  18.                 fileStream.Close();
  19.  
  20.  
  21. requestStream.Close();
  22.  
  23.  
  24.  
  25.                 //FtpWebResponse response = (FtpWebResponse)request.GetResponse();
  26.                 //strMessage = response.StatusDescription;
  27.                 //responseCode = Convert.ToInt32(response.StatusCode);
  28.                 //response.Close();
  29.             }

Expand|Select|Wrap|Line Numbers
  1.         private FtpWebRequest getFTPRequestObject(string strFileName)
  2.         {
  3.             FtpWebRequest requestOb = (FtpWebRequest)WebRequest.Create(Path.Combine(ConstantClass.strFTPsiteUrl, strFileName));
  4.             string strUserName =ConstantClass.USERNAME;
  5.             string strPassword=ConstantClass.PASSWORD;
  6.             requestOb.Credentials = new NetworkCredential(strUserName,strPassword);//("vmftp", "veomed123#");
  7.             requestOb.Method = WebRequestMethods.Ftp.UploadFile;
  8.             requestOb.UseBinary = true;
  9.             requestOb.Timeout = Timeout.Infinite;
  10.             requestOb.ReadWriteTimeout = Timeout.Infinite;
  11.             requestOb.Proxy = null;
  12.  
  13.             requestOb.KeepAlive = true;//false
  14.             requestOb.EnableSsl = false;
  15.             requestOb.UsePassive = false;
  16.             return requestOb;
  17.         }
the listed part is where i have problem with
i have many files to upload
i put them in a queue and am uploading one at a time...
it all works perfect.. but when i have a big file for upload say a 80 mb .ppt file,
it succeed in writing it to ftp site but aftr writing ie after exiting from the code below
Expand|Select|Wrap|Line Numbers
  1.       while (contentLen != 0)
  2.                 {
  3.                     requestStream.Write(buffer, 0, contentLen);
  4.                     contentLen = fileStream.Read(buffer, 0, buffLength);
  5.  
  6.                 }
it gets stuck or waits unconditionally at
Expand|Select|Wrap|Line Numbers
  1. requestStream.Close();
can any one help me out,
Mar 10 '09 #1
0 1204

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

Similar topics

1
by: Techy | last post by:
I have hancoded the asp page for inserting the values into an Ms Access > Database and it work fine > > The problem I am facing is that once I insert any value with Decimals like " > 11.95" or...
2
by: Harag | last post by:
Hi All Using: JScript IIS 5 I have a problem in the following code: // The next 4 lines display exactly what was typed in the text boxes. out("<br>Request.Form="+...
1
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
5
by: fripper | last post by:
I posted this problem a couple of days ago but felt I might have better luck re-stating the problem. Apparently I messed up IIS (v. 5) somehow because I am suddenly unable to load web forms! A...
2
by: Helge Kalnes | last post by:
We are running an ASP.NET application on a cluster of 3 web-servers, using the Network Load Balancing feature of Application Center. We have synchronized the machineKey in machine.config on the 3...
1
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
0
by: Matt | last post by:
I have a problem when I select node elements from an xml file and validata each node againts the schema. I use XmlValidatingReader and it complains about elements not being declared. I have...
102
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.