Ftp Error 553 Filename Not Allowed
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
C# Upload File To Ftp
Learn more about Stack Overflow the company Business Learn more about hiring developers c# ftp or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges 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: Sign up Can't connect to FTP: (553) File name not allowed up vote 4 down vote favorite 3 I need to FTP a file to a directory. In .Net I have to use a file on the destination folder to create a connection so I manually put Blank.dat on the server using FTP. I checked the access (ls -l) and it is -rw-r--r--. But when I attempt to connect to the FTP folder I get: "The remote server returned an error: (553) File name not allowed" back from the server. The research I have done says that this may arrise from a permissions issue but as I have said I have permissions to view the file and can run ls from the folder. What other reasons could cause this issue and is there a way to connect to the folder without having to specify a file? byte[] buffer; Stream reqStream; FileStream stream; FtpWebResponse response; FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(string.Format("ftp://{0}/{1}", SRV, DIR))); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(UID, PASS); request.UseBinary = true; request.Timeout = 60000 * 2; for (int fl = 0; fl < files.Length; fl++) { request.KeepAlive = (files.Length != fl); stream = File.OpenRead(Path.Combine(dir, files[fl])); reqStream = request.GetRequestStream(); buffer = new byte[4096 * 2]; int nRead = 0; while ((nRead = stream.Read(buffer, 0, buffer.Length)) != 0) { reqStream.Write(buffer, 0, nRead); } stream.Close(); reqStream.Close(); response = (FtpWebResponse)request.GetResponse(); response.Close(); } c# .net ftp share|improve this question asked Feb 23 '12 at 17:50 NomadicDeveloper 2712922 1 Whats the filename of the file you wanted to send? –BlueM Feb 23 '12 at 17:53 Did you check the permissions of the folder you wanted to put the
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 the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a http://stackoverflow.com/questions/9418404/cant-connect-to-ftp-553-file-name-not-allowed community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up FTP error: (553) File name not allowed up vote 0 down vote favorite I am trying to ftp a file but i get the following error: The remote server returned an error: (553) File http://stackoverflow.com/questions/23222164/ftp-error-553-file-name-not-allowed name not allowed. at System.Net.FtpWebRequest.SyncRequestCallback(Object obj) at System.Net.FtpWebRequest.RequestCallback(Object obj) at System.Net.CommandStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.Stream.Dispose() at System.Net.ConnectionPool.Destroy(PooledStream pooledStream) at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse) at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage) at System.Net.FtpWebRequest.GetRequestStream() This exception occurs at the following line marked in my snippet below. System.Net.FtpWebRequest clsRequest = (System.Net.FtpWebRequest)System.Net.WebRequest.Create("ftp://" + destination.FTPSite + outputFile); clsRequest.Credentials = new System.Net.NetworkCredential(destination.FTPUserName, destination.FTPPassword); clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile; clsRequest.Timeout = Properties.Settings.Default.FtpTimeOut; // read in file... byte[] bFile = System.IO.File.ReadAllBytes(localFile); // upload file... System.IO.Stream clsStream = clsRequest.GetRequestStream(); <<---- clsStream.Write(bFile, 0, bFile.Length); clsStream.Close(); clsStream.Dispose(); It's trying to send to the following location on the ftp site: send/republicservices/invoice/ File: Republic_20140421_230019.inv This code originally worked in VB.net but now am getting issues in the c# version. Any ideas why? This code also uploads about 6 other files daily without issue. c# .net ftp ftpwebrequest share|improve this question edited Apr 22 '14 at 14:17 Soner Gönül 69.7k22110200 asked Apr 22 '14 at 14:16 user1732364 2711929 add a comment| 2 Answer
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your http://www.codeproject.com/Questions/428936/The-remote-server-returned-an-error-File-name Blog quick answersQ&A Ask a Question View Unanswered Questions View All http://www.dreamincode.net/forums/topic/280812-how-can-i-solve-my-ftp-problem/ Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL ftp error Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research ftp error 553 Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ The remote server returned an error: (553) File name not allowed. Rate this: Please Sign up or sign in to vote. See more: C# Linux FTP Hi I was trying to upload file using ftp.(To a Linux machine). The following is the code, which I have tried. try { string filename = @"C:\Users\Admin\AppData\Local\Temp\Roaming.Doc"; String ftpServerIP = "ftp://192.168.1.246:21/"; FileInfo fileInf = new FileInfo(filename); FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ftpServerIP + "/" + fileInf.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential("abc", "123$"); request.UsePassive = true; request.UseBinary = true; request.KeepAlive = false; //Load the file FileStream stream = Fi
Reply 4 Replies - 6803 Views - Last Post: 27 May 2012 - 12:07 AM Rate Topic: #1 dhaggy1980 New D.I.C Head Reputation: 0 Posts: 13 Joined: 21-May 12 How can I solve my FTP problem? Posted 26 May 2012 - 06:00 PM I am writing a small ftp application for a friend and I'm not sure whats going on here. I'll try to be as descriptive as possible. I get a 553 error "The remote server returned an error: (553) File name not allowed." when I try to upload a file. The Code: Private Sub btnUpload_Click(sender As System.Object, e As System.EventArgs) Handles btnUpload.Click Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://" & txtServer.Text & "/" & rtxtFile.Text), System.Net.FtpWebRequest) request.Credentials = New System.Net.NetworkCredential(txtUserName.Text, txtPassword.Text) request.Method = System.Net.WebRequestMethods.Ftp.UploadFile MsgBox("ftp://" & txtServer.Text & "/" & rtxtFile.Text) Dim file() As Byte = System.IO.File.ReadAllBytes(rtxtFile.Text) Dim strz As System.IO.Stream = request.GetRequestStream() strz.Write(file, 0, file.Length) strz.Close() strz.Dispose() End Sub Private Sub rtxtFile_Click(sender As Object, e As System.EventArgs) Handles rtxtFile.Click Me.ofdFiles.ShowDialog() End Sub Private Sub ofdFiles_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ofdFiles.FileOk rtxtFile.Text = ofdFiles.FileName End Sub I added a msgbox to show me what the path to the server is and this is it. Click OK and it gives me the error above. So I changed the "ofd.Files.FileName to ofd.Files.SafeFileName My msgbox now shows this: Then VS throws en error saying it can't find the file in the projects debug folder so I move it there and run the program and it uploads. I noticed that in the first msgbox it has forward and backward slashes could that be my problem or is it something else? Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: How can I solve my FTP problem? #2 tlhIn`toq Xamarin Cert. Dev. Reputation: 6352 Posts: 13,992 Joined: 02-June 10 Re: How can I solve my FTP problem? Posted 26 May 2012 - 07:19 PM Its not just the slashes... Look at the file path... ftp://site.org/C:\ blah blah How in any way would you think that is a valid file path? Was This Post Helpful? 1 Back to top MultiQuote Quote + Reply #3 dhaggy1980 New D.I.C Head Reputation: 0 Posts: 13 Joined: 21-May 12 Re: How can I solve my FTP problem? Posted 26 May 2012 - 08:21 PM Ok, so is there a way to fix that. Like trimming or something. I don't want to have to put the file to upload in the program folder everytime I upload something. Was This Post He