473,492 Members | 4,279 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Uploading folder to ftp

37 New Member
I am trying to upload images to the ftp. I need to have it in a compressed folder called by a specific name and then upload that folder to a specific directory. Each time I try, I get an error The remote server returned an error: (550) File unavailable
This code works fine when I am trying to upload one image at a time. Here I am trying to upload a whole folder. I checked the uri (I copied it from the debugging) and it went there just fine. Is there a different way that I have to do the upload folders?

It doesn't really sound like it can be a permissions problem, because I am able to upload a file via filezilla. I am also able to use a command prompt and cd into the proper folder. Anyone know what the problem is? I am pretty desperate?

Expand|Select|Wrap|Line Numbers
  1.  
  2.   string ftpPassword = ConfigurationManager.AppSettings["ftpPassword"].ToString();
  3.       string uri = remoteDirectory;
  4.       FileInfo fileInf = new FileInfo(FileToUpload);
  5.       // Create FtpWebRequest object from the Uri provided
  6.       FtpWebRequest reqFTP = null;
  7.       reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
  8.       reqFTP.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
  9.       reqFTP.KeepAlive = false;
  10.       reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
  11.       // Specify the data transfer type.
  12.       reqFTP.UseBinary = true;
  13.       // Notify the server about the size of the uploaded file
  14.       reqFTP.ContentLength = fileInf.Length;
  15.       // The buffer size is set to 2kb
  16.       int buffLength = 2048;
  17.       byte[] buff = new byte[buffLength];
  18.       int contentLen;
  19.       // open file to be uploaded
  20.       using (FileStream fs = fileInf.OpenRead())
  21.       {
  22.       try
  23.       {
  24.       // Stream to which the file to be upload is written
  25.       using (Stream strm = reqFTP.GetRequestStream())
  26.       {
  27.       // Read from the file stream 2kb at a time till Stream content ends
  28.       contentLen = fs.Read(buff, 0, buffLength);
  29.       while (contentLen != 0)
  30.       {
  31.       // Write Content from the file stream to the FTP Upload Stream
  32.       strm.Write(buff, 0, contentLen);
  33.       contentLen = fs.Read(buff, 0, buffLength);
  34.       }
  35.       }
  36.       reqFTP = null;
  37.       ////Update the database with the new image location and delete the img from the uploadedimages folder
  38.       //DataAccess.UpdateImageDB(item.ProductID, item.ImgFolder + "/" + item.IMG);
  39.       System.IO.File.Delete(fileInf.ToString());
  40.       }
  41.       {
  42.       Console.WriteLine(ex.Message, "Upload Error");
  43.       }
  44.  
Dec 15 '10 #1
0 2020

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

Similar topics

3
486
by: R Reyes | last post by:
what are the pros/cons of uploading a file into a database (like access, sql server, oracle) vs. uploading a file into a folder (and only storing its path in a database table) ? i've never had...
21
66767
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what...
3
1939
by: deko | last post by:
Newbie ASP.NET question: Now that I've created an ASP.NET site, how to I get it to my hosting provider? I've developed sites with Dreamweaver MX in the past - with Dreamweaver, it's very...
2
1548
by: Jay | last post by:
This has to do with uploading files to a folder on the web server. In http://support.microsoft.com/kb/323246 it indicates that the permissions on the folder you are uploading to should be set...
7
1446
by: chuckdfoster | last post by:
I am developing an ASP.NET site where an site administrator can upload files via ASP.NET into a Documents folder. These documents are then viewed by site users. I used the MS KB article...
4
1630
by: Ramakrishnan Nagarajan | last post by:
Hi, I am facing a different problem in my application. In that I am uploading a folder that contain only images. Everything was done and was working fine too. When I executed the application using...
0
1847
by: lknight643 | last post by:
I have an asp.net application that works with a SQL server database on server No. 1 but I want to upload files for storage to Server No. 2 that is accessible only from the Internet. If the file...
2
2720
by: Kausar | last post by:
Hello All, I want to know how to scan the files before uploading it to the server in ASP.NET 2.0 application. One work arround i thought is to allow to upload in some temporary folder then sacn...
1
1522
by: Larry Bates | last post by:
I have a need to implement a drop folder upload mechanism for secure uploading of files to a server. At first glance this appears that it would be an easy application to write. Then I begin to...
3
1899
ganesanji
by: ganesanji | last post by:
hi all, I have written a php coding for uploading a file to a specific folder or location in server which is a Linux server. I think the coding for file uploaing is correct. But it does not...
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
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
7192
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6862
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7364
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
5452
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,...
0
3087
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
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.