C# Ftp Getrequeststream Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow c# getrequeststream cannot send a content-body with this verb-type the company Business Learn more about hiring developers or posting ads with us Stack
C# Getrequeststream Timeout
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community c# httpwebrequest getrequeststream of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up FTP, GetResponse (), error 550 File unavailable up vote 13 down vote favorite 2 I have created
Ftpwebrequest Getrequeststream
a small windows forms application to upload the file to one of our client's ftp site. But the problem that I'm having is that when I run this application on my local machine it uploads the file successfully. But if I run this program on our server, I get this error message; remote server returned an error: (550) File unavailable (eg, file not found, can not access the file), on this line the remote server returned an error (550) file unavailable (e.g. file not found no access). ftp c# 'objFTPRequest.GetRequestStream();'. Does anybody know why? Do I need to configure the firewall or something? Here is my code; FileInfo objFile = new FileInfo(filename); FtpWebRequest objFTPRequest; // Create FtpWebRequest object objFTPRequest = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/outbox/" + objFile.Name)); // Set Credintials objFTPRequest.Credentials = new NetworkCredential(ftpUserName, ftpPassword); // By default KeepAlive is true, where the control connection is // not closed after a command is executed. objFTPRequest.KeepAlive = false; // Set the data transfer type. objFTPRequest.UseBinary = true; // Set content length objFTPRequest.ContentLength = objFile.Length; // Set request method objFTPRequest.Method = WebRequestMethods.Ftp.UploadFile; // Set buffer size int intBufferLength = 16 * 1024; byte[] objBuffer = new byte[intBufferLength]; // Opens a file to read FileStream objFileStream = objFile.OpenRead(); // Get Stream of the file Stream objStream = objFTPRequest.GetRequestStream(); int len = 0; while ((len = objFileStream.Read(objBuffer, 0, intBufferLength)) != 0) { // Write file Content objStream.Write(objBuffer, 0, len); } objStream.Close(); objFileStream.Close(); c# .net file-upload ftp share|improve this question edited Sep 16 '15 at 7:44 Irshad 2,29251534 asked Jul 4 '13 at 13:37 chosenOne Thabs 2133717 add a comment| 7 Answers 7 active oldest votes up vote 12 down vote This error can be caused because of several reasons like file is not present on server, security permissions on file etc. etc. First you nee
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
550 File Not Found Ftp
of this site About Us Learn more about Stack Overflow the company Business
System.net.webexception: The Remote Server Returned An Error: (550) File Unavailable
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges the remote server returned an error (550) web deploy Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/17471745/ftp-getresponse-error-550-file-unavailable Sign up Uploading a file to a ftp server fails up vote 1 down vote favorite I have a small C# winform in which I generate some text files and then move them to an ftp server. When I try to move them to the production server it fails under The remote server returned an error: (530) Not logged in. If I log http://stackoverflow.com/questions/20066197/uploading-a-file-to-a-ftp-server-fails in to the ftp via cmd/ftp with the same ftp address, username and password, everything is ok. I also installed a local ftp server on my machine and tested it to see if perhaps my code is generating the error, but locally it works like a charm, I have the problem only with the production ftp server. Below is my code to connect and upload the files to the ftp server: string[] FileName = Directory.GetFiles(outputpath); foreach (string txtFile in FileName) { FileInfo toUpload = new FileInfo(txtFile); FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + tbFTPAddress.Text + @"//" + toUpload.Name); request.Credentials = new NetworkCredential(tbFTPUserName.Text.Trim(), tbFTPPassword.Text.Trim()); request.Method = WebRequestMethods.Ftp.UploadFile; Stream ftpStream = request.GetRequestStream(); FileStream file = File.OpenRead(txtFile); int length = 1024; byte[] buffer = new byte[length]; int bytesRead = 0; try { do { bytesRead = file.Read(buffer, 0, length); ftpStream.Write(buffer, 0, bytesRead); } while (bytesRead != 0); file.Close(); ftpStream.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error encountered!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (file != null) file.Close(); if (ftpStream != null) ftpStream.Close(); } } The error comes at: Stream ftpStream = request.GetRequestStream(); Any ideas? Thanks! c# ftp stream filestream ftpw
My language of choice is C# in Windows, ASP.NET Web Forms, and MVC. My latest dabblings https://nickstips.wordpress.com/2010/10/25/c-ftp-upload-error-the-remote-server-returned-an-error-550-file-unavailable-e-g-file-not-found-no-access/ have been with Android Applications, ASP.NET AJAX enabled websites, ASP.NET http://www.dreamincode.net/forums/topic/76361-file-upload-to-server/ MVC, Silverlight, and HTML5. Categories .NET Framework (6) AJAX (6) ASP.NET (5) ASP.NET MVC (17) Collections (4) Comparisons (1) Crystal Reports (3) Dependency Injection (1) Extension Methods (3) Hashing (1) HTML5 (3) IIS (2) jQuery (6) LINQ (7) Networking (2) Office Automation (1) the remote Security (3) Silverlight (4) Sorting (3) SQL (13) String Manipulation (11) Time and Date (2) Uncategorized (1) Unit Testing (1) Visual Studio (2) Windows 7 (7) Windows Forms (7) Tag Cloud .NET Framework 64-bit 404 550 ActiveX AJAX ASP.NET ASP.NET AJAX Toolkit ASP.NET MVC authentication Bananagrams Bandwidth C# Canvas Casting Client Side Validation the remote server Collections ComboBox Comparisons Crystal Reports DataGridView Date Dependency Injection dialog Extension Method FTP Game Hashing HTML5 IIS Iversion of Control JavaScript jQuery jQuery UI LINQ LINQ to XML List ListView Mail Merge MD5 Microsoft Word Mocking Moq MVC Networking Ninject Numbers Office Automation Parsing qTip Random Routing Security Server Side Validation Set Silverlight SMSS Sorting Split SQL SSL SSMS String Strings Time Truncate Unit Testing Validation version Visual Studio Windows 7 Windows Forms Windows Gadget Windows Installer WordPress C#: FTP Upload Error - The remote server returned an error: (550) File unavailable (e.g., file not found, noaccess). October 25, 2010 -- Nick Olsen I developed an application a while back that automatically backs up a group of SQL servers every night and then uploads the backups to an offsite location using FTP. The application has worked flawlessly for months now so I was quite surprised to get a call this morning saying that the automatic backups faile
6 Replies - 43626 Views - Last Post: 12 January 2010 - 05:41 PM Rate Topic: #1 balakit New D.I.C Head Reputation: 0 Posts: 7 Joined: 20-November 08 File Upload to server Posted 12 December 2008 - 12:24 AM Hi, I need to upload file in a folder at FTP server, The code i used is, FileInfo filename = new FileInfo(txtfilurl.Text); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(txtaddr.Text + "/" + filename.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(txtuser.Text, txtpass.Text); request.KeepAlive = false; request.UseBinary = true; Stream ftpstream = request.GetRequestStream();//-->This line shows the error FileStream file = File.OpenRead(txtfilurl.Text); int len = 1024; byte[] buff = new byte[len]; int bytesread = 0; do { bytesread = file.Read(buff, 0, len); ftpstream.Write(buff, 0, bytesread); } while (bytesread != 0); file.Close(); ftpstream.Close(); Error msg is:Web exception The remote server returned an error: (550) File unavailable (e.g., file not found, no access). Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: File Upload to server #2 eclipsed4utoo Not Your Ordinary Programmer Reputation: 1532 Posts: 5,969 Joined: 21-March 08 Re: File Upload to server Posted 12 December 2008 - 06:43 AM balakit, on 12 Dec, 2008 - 02:24 AM, said:Hi, I need to upload file in a folder at FTP server, The code i used is, FileInfo filename = new FileInfo(txtfilurl.Text); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(txtaddr.Text + "/" + filename.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(txtuser.Text, txtpass.Text&