thanks for the help. It looked like a promising solution but unfortunately did not solve my problem.
I'm trying to read a string from a text file so I can encrypt it.
When I create the text file manually, it reads and encrypts correctly.
If I try to create the text file dynamically, it encrypts to a slightly different outcome.
I can't understand why the difference.
<code>
Private Shared ReadOnly encryptionKeyBytes() As Byte = New Byte() {53, 53, 53, 53, 53, 53, 53, 53}
Private Shared Function GenerateEncryptedLicFile(ByVal inputText As String, ByVal outputFile As String) As Boolean
Dim outputStream As Stream = Nothing
Dim encryptedStream As Stream = Nothing
Dim result As Boolean = False
Dim des As DESCryptoServiceProvider = New DESCryptoServiceProvider()
des.Key = encryptionKeyBytes
des.IV = encryptionKeyBytes
Try
outputStream = New FileStream(outputFile, FileMode.Create, FileAccess.Write, FileShare.None)
Dim desEncryptor As ICryptoTransform = des.CreateEncryptor()
encryptedStream = New CryptoStream(outputStream, desEncryptor, CryptoStreamMode.Write)
Dim contents() As Byte = des.EncryptValue(inputText)
encryptedStream.Write(contents, 0, contents.Length)
result = True
Finally
If Not encryptedStream Is Nothing Then
encryptedStream.Close()
encryptedStream = Nothing
End If
If Not outputStream Is Nothing Then
outputStream.Close()
outputStream = Nothing
End If
End Try
Return result
End Function
</code>
"Tim_Mac" <ti********@community.nospamwrote in message news:eZ**************@TK2MSFTNGP04.phx.gbl...
you could just use Trim() on the string which should remove any whitespace off either end of the line.
but if you want to use regex...
\r is carriage return
\n is newline
a simple replace on these characters with the empty string will sort it out.
System.Text.RegularExpressions.Regex.Replace(input , @"\r\n", "");
hope this helps
tim
"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message news:%2****************@TK2MSFTNGP04.phx.gbl...
>when reading a string from a file how to clean off "new line" and "end of line" stuff so text is returned as a clean single line
?