English 中文(简体)
利用Ftpwebrequest上载固定宽度,PRN文档到主机。 每一记录均缩为80个。
原标题:Using Ftpwebrequest to upload fixed width .PRN file to Mainframe. Each record is truncated to 80 characters

I m利用偷窃网点将一些档案上载到我们拥有的旧主机系统(MPE/IX)。

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.

如果选择使用日元=作为ASCII文件的有效载荷,则在主机上生成每张记录,但每条线/记录按80个特性分类。

我怎么能够把性质编号定为176。

感谢!

这就是我所说的“Im”号法典,该法典将档案放在主人手中,然后向适当的人发送电子邮件。

    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
最佳回答

查阅到档案名称结尾处的有<代码>;rec=-176。 类似情况:

Response = ftp.Upload(File, "ftp://SERVERNAME/FILENAME" & i & ";rec=-176", credential)
问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签