Поток не поддерживает запись
Извините, у меня есть программа, и я получил какую-то ошибку. есть ошибка в "
cs.Write(bytBuffer, 0, intBytesInCurrentBlock)"Поток не поддерживает запись. Пожалуйста, помогите мне в учебе. спасибо, извините за мой плохой английский.
Что я уже пробовал:
Private Sub enkripataudekrip(ByVal inputfile As String, ByVal outputfile As String, ByVal secret As String, ByVal direction As aksikripto) Dim fsinput As New FileStream(inputfile, FileMode.Open, FileAccess.Read) Dim fsoutput As New FileStream(outputfile, FileMode.OpenOrCreate, FileAccess.Write) fsoutput.SetLength(0) Dim skey As String = "aaaaaaaa" Dim bytBuffer(4096) As Byte 'holds a block of bytes for processing Dim lngBytesProcessed As Long = 0 'running count of bytes processed Dim lngFileLength As Long = fsinput.Length 'the input file's length Dim intBytesInCurrentBlock As Integer 'current bytes being processed Dim cs As CryptoStream Dim des As New DESCryptoServiceProvider des.Key = ASCIIEncoding.ASCII.GetBytes(skey) des.IV = ASCIIEncoding.ASCII.GetBytes(skey) Select Case direction Case aksikripto.enkrip cs = New CryptoStream(fsoutput, des.CreateEncryptor, CryptoStreamMode.Write) 'Dim bytearrayinput(fsinput.Length - 1) As Byte 'fsinput.Read(bytearrayinput, 0, bytearrayinput.Length) 'cs.Write(bytearrayinput, 0, bytearrayinput.Length) 'cs.Close() Case aksikripto.dekrip 'Dim des As New DESCryptoServiceProvider cs = New CryptoStream(fsinput, des.CreateDecryptor, CryptoStreamMode.Read) 'Dim fsdekrip As New StreamWriter(outputfile) 'fsdekrip.Write(New StreamReader(csdec).ReadToEnd) 'fsdekrip.Flush() 'fsdekrip.Close() End Select While lngBytesProcessed < lngFileLength intBytesInCurrentBlock = fsinput.Read(bytBuffer, 0, 4096) cs.Write(bytBuffer, 0, intBytesInCurrentBlock) 'Stream does not support writing End While cs.Close() fsinput.Close() fsoutput.Close() End Sub