Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

FTP upload to OpenVMS using VB.NET

Posted on 2008-06-16
2
1,337 Views
Last Modified: 2013-12-06
I am attempting to FTP a file with a specific format to an OpenVMS system, using the VB.NET FtpWebRequest object (see code snippet).  The strExportText string is given a value by opening a .txt file and reading in the contents.  The text file contains 3 lines of text.  The code below will successfully make the connection, stream the bytes, and end the connection.  When the file is opened on the OpenVMS side, the carriage returns are not being recognized.  There should be 3 lines of text, where now there is one continuous line with the letters CR and LF at the carriage return and line feed positions.  What settings need to be set in order for the OpenVMS to understand the characters?
Private Function ExportShipped(ByVal strExportText As String) As DBReturn
        Dim dbrReturn As DBReturn = DBReturn.Fail
        Dim ftpReq As FtpWebRequest
        Dim ftpStream As IO.Stream
        Dim bytExportText(strExportText.Length) As Byte
        Dim sdrSOExportInfo As SqlDataReader
        Dim strFTPDirectory As String
        Dim strFileName As String
        Dim strUserName As String
        Dim strPassword As String
        
        Try
            sdrSOExportInfo = mobjDBShipping.GetSOExportInfo()
            If sdrSOExportInfo.Read Then
                strFTPDirectory = sdrSOExportInfo(db_Shipping.SOExportIX.OutputDirectory).ToString
                strFileName = sdrSOExportInfo(db_Shipping.SOExportIX.OutputFileName).ToString
                strUserName = sdrSOExportInfo(db_Shipping.SOExportIX.Username).ToString
                strPassword = sdrSOExportInfo(db_Shipping.SOExportIX.Password).ToString
 
                ftpReq = FtpWebRequest.Create(strFTPDirectory & "\" & strFileName)
                ftpReq.Credentials = New NetworkCredential(strUserName, strPassword)
                ftpReq.Method = WebRequestMethods.Ftp.UploadFile
	       ftpReq.UseBinary = True
 
                bytExportText = Encoding.Default.GetBytes(strExportText)
                ftpReq.ContentLength = bytExportText.Length
 
                ftpStream = ftpReq.GetRequestStream
                ftpStream.Write(bytExportText, 0, bytExportText.Length)
                ftpStream.Close()
 
                'ftpResponse = ftpReq.GetResponse()
 
                '("Upload File Complete, status {0}", ftpResponse.StatusDescription)
 
                '  ftpResponse.Close()
                dbrReturn = DBReturn.Success
 
            Else
                dbrReturn = DBReturn.Fail
            End If
 
        Catch ex As Exception
            Throw ex
        End Try
 
        Return dbrReturn
    End Function

Open in new window

0
Comment
Question by:pprater1
2 Comments
 
LVL 4

Accepted Solution

by:
jmfairchild earned 500 total points
ID: 21797537
I believe that your problem may lie in the binary transfer. It has been awhile since I worked with VMS, but I believe you will have to FTP the file in ASCII format to ensure it gets read properly on the OpenVMS end. Try setting the UseBinary statement to ftpReq.UseBinary = False. If that doesn't work, or you can't use it for some reason, you will need to convert the file on the other (OpenVMS) end. If so, I could probably scare up an old DCL command file that would do the trick if you would feel comfortable with that solution.
0
 

Author Closing Comment

by:pprater1
ID: 31467712
I ended up trying this before you posted and it is absolutely correct.  I used a combination of setting UseBinary = False and the Encoding in line #25 to ASCII.  Not exactly sure why it wanted straight text instead of binary, but it worked.  Thanks for your help!!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Call Controller Action Method from ASPX 2 22
Oracle DB Slows After Datapump Until Next Reboot 27 93
SOA*.tmp files 2 46
Code enhancement 4 22
I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question