My goal is to upload a string to a txt file on an ftp server.

Here is what I have found so far:

vb Code:
  1. Dim clsRequest As System.Net.FtpWebRequest = _
  2.             DirectCast(System.Net.WebRequest.Create(RemoteFilename), System.Net.FtpWebRequest)
  3.         clsRequest.Credentials = New System.Net.NetworkCredential("usr", "pw")
  4.         clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
  5.  
  6. 'write the string to a local text file
  7.         Dim Report as String = "Test Report"
  8.         Dim ReportFile As String = "C:\report.txt"
  9.         Dim strWriter As IO.StreamWriter
  10.         strWriter = New IO.StreamWriter(ReportFile)
  11.         strWriter.Write(Report)
  12.         strWriter.Close()
  13.  
  14.         ' read in file
  15.         Dim bFile() As Byte = System.IO.File.ReadAllBytes(ReportFile)
  16.  
  17.         ' upload file
  18.         Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
  19.         clsStream.Write(bFile, 0, bFile.Length)
  20.         clsStream.Close()
  21.         clsStream.Dispose()

It seems pretty silly to do it like this! (write the file and then immediately read it again). Is there a way to convert a String into something that clsStream.Write will accept?

Thanks,

Dave