Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8389845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:49:52+00:00 2026-06-09T18:49:52+00:00

I write a piece of code just for testing to send txt file with

  • 0

I write a piece of code just for testing to send txt file with type ASCII to FTP server, but keep getting following error.

The remote server returned an error: (501) Syntax error in parameters or arguments.

I am sure the user name and password is correct, and I tried to set UsePassive true and false but get same error.

The following is the code I used.

Imports System.IO
Imports System.Text
Imports System.Net

Module Module1

Sub Main()
    Dim lPOSByteArray() As Byte
    Dim lEncoding As New ASCIIEncoding
    Dim lPOSFlatFile As String
    lPOSFlatFile = System.IO.File.ReadAllText("C:\\Users\\somebody\\Desktop\\Test.config.XML")
    lPOSByteArray = lEncoding.GetBytes(lPOSFlatFile)

    Dim lFTPrequest As System.Net.FtpWebRequest

    lFTPrequest = DirectCast(WebRequest.Create("ftp://" & "199.222.111.111" & "/" & "Test.txt"), System.Net.FtpWebRequest)
    lFTPrequest.Proxy = Nothing
    lFTPrequest.Credentials = New NetworkCredential("userxxx", "passyyy")
    lFTPrequest.Method = WebRequestMethods.Ftp.UploadFile
    lFTPrequest.UseBinary = False
    lFTPrequest.UsePassive = True
    lFTPrequest.ContentLength = lPOSByteArray.Length

    'ERROR happened on following line
    Dim lFTPrequestStream As Stream = lFTPrequest.GetRequestStream()
    lFTPrequestStream.Write(lPOSByteArray, 0, lPOSByteArray.Length)
    lFTPrequestStream.Close()

    Dim response As System.Net.FtpWebResponse = DirectCast(lFTPrequest.GetResponse(), System.Net.FtpWebResponse)

End Sub

End Module

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:49:54+00:00Added an answer on June 9, 2026 at 6:49 pm

    I think that your code is right. The problem is in another place, like network or ftp server. I tried with my FTP server and changed the line

     lPOSByteArray = lEncoding.GetBytes(lPOSFlatFile)
    

    to

     lPOSByteArray = lEncoding.GetBytes("test")
    

    and works fine. Can you read/write this file with a ftp client like FileZila?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a piece of code that reads a file line by
Hi this is a very simple piece of code I just write for C++
I'm trying to write a piece of code which use the user choice in
I'm trying to write a piece of code that takes in a two digit
I was trying to write a piece of code for converting a list of
Is it worth to write this piece of code: RelayCommand _saveCommand; public ICommand SaveCommand
Hi I'm trying to write a piece of code for a simple verification method
Begginer's question. I'm trying to write small piece of code in Visual Studio (VB.net)
I write a simple piece of code that creates a div and assign it
I'm trying to write a little piece of code to show in a portlet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.