The remote server returned an error: (553) File name not allowed

123 Views Asked by At

I am traying to transfer data from my locale computer to a distant one with FTP using this VB code

Dim fwr As FtpWebRequest = FtpWebRequest.Create(FTPURL)
fwr.Credentials = New NetworkCredential (FTPUserName , FTPPassword) 
fwr.KeepAlive = False 
fwr.UseBinary = True 
fwr.Timeout = 20000
fwr.Method = WebRequestMethods.Ftp.UploadFile 


Dim FileInfo As System.IO.FileInfo(LocalFilePath + LocalFileName)
Dim FileLength as Integer = FileInfo.Length 
fwr.ContentLength = FileLength 

Dim buffLength as Integer 
if FileInfo.Length < 131072 Then 
  buffLength = FileLength 
else 
  BuffLength = 131072 
end if 
Dim buff(buffLength - 1 ) As Byte 

Dim fstream As System.IO.FileStream = FileInfo.OpenRead() 

Try 
   Dim FTPStream As System.IO.Stream = fwr.GetRequestStream()
   Dim contentLen As Integer = fstream.Read( buff , 0 , buffLength ) 
  

   Do Wile contentLen <> 0 
   FTPStream.Write(buff, 0 , contentLen)
   contentLen = fstream.Read(buff , 0 , buffLength) 
   Loop 



   FTPStream.Close()
   FTPStream.Dispose() 
   fstream.Close() 
   fstream.Dispose() 

   Catch ex As Exception
     ErrorMessage = ex.Message 

   End Try 
   fwr = Nothing 

When i try to transfer file with a lambda user it's show me the error The remote server returned an error: (553) File name not allowed. but when i use root user it's working OK

0

There are 0 best solutions below