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

  • Home
  • SEARCH
  • 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 6240713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:37:17+00:00 2026-05-24T11:37:17+00:00

I’m using ftpwebrequest to upload some files to an old mainframe system (MPE/IX) that

  • 0

I’m using ftpwebrequest to upload some files to an old mainframe system (MPE/IX) that we have.

The file is a .prn file and essentially has many records which are fixed width and no delimiter. Each record is 176 characters long, and has a CRLF at the end.

If choose usebinary = false to upload as an ASCII file it creates the file with each record on the mainframe, but each line/record is truncated at 80 characters.

How can I specify number of characters as 176.

Thanks!

This is the Code I’m using which like I said gets the file to mainframe and then sends out emails to the appropriate people.

    Public Sub Main()
    Dim i As Integer = 1
    Dim credential As NetworkCredential

    Try
        EmailList = ReadEmailAddress()
        credential = New NetworkCredential("USERNAME", String.Empty)
        FileList.AddRange({"CAN04_30030_", "CAN04_34120_", "CSI01_30030_", "CSI01_34120_"})

        For Each FileName In FileList
            Dim File As FileInfo
            Dim Response As ArrayList

            Try
                File = New FileInfo(IO.Path.Combine(SourceFileFolder, FileName & Now.ToString("yyyyMMdd") & ".prn"))

                If File.Exists Then
                    Response = ftp.Upload(File, "ftp://SERVERNAME/FILENAME" & i, credential)
                    UploadResults.Add(Response(1))
                Else
                    UploadResults.Add("<font color=""red"">" & File.Name & " was not found in the folder " & SourceFileFolder & "</font>")
                End If

                If Not Response Is Nothing Then
                    If Response(0) = 226 Then ArchiveFile(File)
                End If

            Catch ex As Exception
                UploadResults.Add("<font color=""red"">" & ex.Message & " occurred while trying to upload the file " & File.Name & "</font>")
            Finally
                File = Nothing
                Response = Nothing
            End Try

            i += 1
        Next

        SendMail()
    Catch ex As Exception

    Finally
        credential = Nothing
    End Try


End Sub  


Public Function Upload(ByVal File As FileInfo, ByVal target As String, ByVal credential As NetworkCredential) As ArrayList
    Dim AList As New ArrayList

    Try
        request = DirectCast(WebRequest.Create(target), FtpWebRequest)

        With request
            .Method = WebRequestMethods.Ftp.UploadFile
            .UsePassive = True
            .Credentials = credential
            .KeepAlive = False
            .UseBinary = False
        End With

        Dim sourceStream As StreamReader = New StreamReader(File.FullName, True)
        Dim filecontents() As Byte = Encoding.ASCII.GetBytes(sourceStream.ReadToEnd)
        sourceStream.Close()
        request.ContentLength = filecontents.Length

        Dim stream As Stream = request.GetRequestStream
        stream.Write(filecontents, 0, filecontents.Length)
        stream.Flush()
        stream.Close()

        response = DirectCast(request.GetResponse, FtpWebResponse)

        Dim t() As String = Split(target, "/")

        Try
            AList.Add(response.StatusCode)
        Catch ex As Exception
            AList.Add(String.Empty)
        End Try


        If response.StatusCode = 226 Then
            AList.Add(File.Name & " (" & t(t.GetUpperBound(0)) & ") " & " was transferred to " & UCase(credential.UserName) & " [<i>" & Split(response.StatusDescription, ".")(0) & "</i>]")
        Else
            AList.Add(File.Name & " (" & t(t.GetUpperBound(0)) & ") " & " was NOT transferred to " & UCase(credential.UserName) & " [<i>" & Split(response.StatusDescription, ".")(0) & "</i>]")
        End If

    Catch ex As Exception
        AList.Add(File.Name & " was NOT transferred.  " & ex.Message.ToString)
    Finally
        response.Close()
        request = Nothing
        response = Nothing
        File = Nothing
    End Try
    Return AList
End Function
  • 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-05-24T11:37:18+00:00Added an answer on May 24, 2026 at 11:37 am

    It looks like you just have to append ;rec=-176 to the end of the filename. Try something like this:

    Response = ftp.Upload(File, "ftp://SERVERNAME/FILENAME" & i & ";rec=-176", credential)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.