Click here to Skip to main content
15,891,657 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: problem to translate C# to VB .NET Pin
Denis999910-Jan-11 3:28
Denis999910-Jan-11 3:28 
GeneralRe: problem to translate C# to VB .NET Pin
Simon_Whale10-Jan-11 3:34
Simon_Whale10-Jan-11 3:34 
AnswerRe: problem to translate C# to VB .NET Pin
Dalek Dave10-Jan-11 3:40
professionalDalek Dave10-Jan-11 3:40 
GeneralRe: problem to translate C# to VB .NET Pin
Simon_Whale10-Jan-11 3:41
Simon_Whale10-Jan-11 3:41 
GeneralRe: problem to translate C# to VB .NET Pin
Dalek Dave10-Jan-11 3:46
professionalDalek Dave10-Jan-11 3:46 
GeneralRe: problem to translate C# to VB .NET Pin
Denis999910-Jan-11 4:13
Denis999910-Jan-11 4:13 
AnswerRe: problem to translate C# to VB .NET Pin
Ray Cassick10-Jan-11 6:42
Ray Cassick10-Jan-11 6:42 
QuestionError: Length of Data to decrypt is invalid Pin
crain19819-Jan-11 5:10
crain19819-Jan-11 5:10 
Can anyone help me solve this problem? It give me this error at crypto.close. Any Suggestions?
Try

    'checking to make sure the text box isn't null'
    If (Decrypt_TextBox.Text = "") Then
        MessageBox.Show("Need to put in the file location or select file in grid for decryption")
    Else

        'declaring string for file'
        Dim filename As String
        'Getting the file name that is selected'

        filename = getFilename()
        'Starting to abstract the data from the database'
        database.ConnectionString = "Data Source = [name of database].db3;"
        database.Open()
        Dim command As SQLite.SQLiteCommand
        Dim sqlstatement As String
        command = database.CreateCommand
        'The following will get the bytes of the file'
        Dim filesize As Integer
        sqlstatement = "SELECT FileSize From [table name] WHERE FileName=@file;"
        command.CommandText = sqlstatement
        command.Parameters.AddWithValue("@file", filename)
        Dim reader As SQLite.SQLiteDataReader
        reader = command.ExecuteReader
        filesize = reader.GetValue(0)
        reader.Close()
        MessageBox.Show(filesize)
        Dim data(filesize) As Byte
        'The following should get the data'
        sqlstatement = "SELECT FileData FROM [table name] WHERE FileName=@file;"
        command.CommandText = sqlstatement
        command.Parameters.AddWithValue("@file", filename)

        Dim buf() As Byte


        'This gets the file from the database'
        reader = command.ExecuteReader


        'The following should get the file back to its original form'
        buf = reader.GetValue(0)
        MessageBox.Show(buf.Length)



        'This is go into the Safe and retrieve file'
        Dim datawrite As New System.IO.FileStream("filename", IO.FileMode.Open, IO.FileAccess.ReadWrite)
        datawrite.SetLength(0)
        datawrite.Write(buf, 0, buf.Length)
        datawrite.Close()
        reader.Close()
        Dim fileinput As New System.IO.FileStream("filename", IO.FileMode.Open, IO.FileAccess.ReadWrite)

        'specific file output location wiht proper extension'
        Dim fileoutput As New System.IO.FileStream(Decrypt_TextBox.Text & "\" & filename, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
        'The next line makes sure that the file is empty'

        'Declaring variables for encryption'

        Dim buffer(4096) As Byte 'Holds the bytes for processing

        Dim BytesProcessed As Double 'running count for bytes that are processed'

        Dim filelength As Double = fileinput.Length() 'Length of file coming in where intEnd will be greater than intStart'

        Dim bytesinblock As Integer 'current bytes in block'

        Dim crypto As CryptoStream

        'Declaring crypto service provider'
        Dim scRijndael As New System.Security.Cryptography.RijndaelManaged

        'setting up progress bars
        Encrypt_ProgressBar.Value = 0
        Encrypt_ProgressBar.Maximum = 100

        crypto = New CryptoStream(fileoutput, scRijndael.CreateDecryptor(key, IV), CryptoStreamMode.Write)

        While BytesProcessed < filelength
            'reading the file'
            bytesinblock = fileinput.Read(buffer, 0, 4096)
            'writing the file to cryptoStream'
            crypto.Write(buffer, 0, bytesinblock)
            'updating bytes processed'
            BytesProcessed = BytesProcessed + CLng(bytesinblock)
            'equation for updating bytes in block'
            Decrypt_ProgressBar.Value = CInt((BytesProcessed / filelength) * 100)
        End While

        crypto.Close()

        fileoutput.Close()
        fileinput.Close()

        MessageBox.Show("File is done decrypting")
        Decrypt_ProgressBar.Step = 0
        Decrypt_ProgressBar.Value = 0
        Decrypt_TextBox.Text = ""
    End If

Catch ex As Exception
    MsgBox(ex.Message.ToString)


End Try

Return 1

AnswerRe: Error: Length of Data to decrypt is invalid Pin
crain19819-Jan-11 5:11
crain19819-Jan-11 5:11 
AnswerRe: Error: Length of Data to decrypt is invalid Pin
Simon_Whale9-Jan-11 22:06
Simon_Whale9-Jan-11 22:06 
QuestionSound Recognition Pin
Synth_Boy7-Jan-11 22:10
Synth_Boy7-Jan-11 22:10 
AnswerRe: Sound Recognition Pin
Bernhard Hiller10-Jan-11 0:04
Bernhard Hiller10-Jan-11 0:04 
GeneralRe: Sound Recognition Pin
Synth_Boy10-Jan-11 0:08
Synth_Boy10-Jan-11 0:08 
QuestionStrange SQL Compact Problem - Vista Pin
TheComputerMan7-Jan-11 7:23
TheComputerMan7-Jan-11 7:23 
AnswerRe: Strange SQL Compact Problem - Vista Pin
Richard MacCutchan7-Jan-11 21:16
mveRichard MacCutchan7-Jan-11 21:16 
GeneralRe: Strange SQL Compact Problem - Vista Pin
TheComputerMan8-Jan-11 16:26
TheComputerMan8-Jan-11 16:26 
GeneralRe: Strange SQL Compact Problem - Vista Pin
Richard MacCutchan8-Jan-11 21:39
mveRichard MacCutchan8-Jan-11 21:39 
GeneralRe: Strange SQL Compact Problem - Vista Pin
TheComputerMan9-Jan-11 1:59
TheComputerMan9-Jan-11 1:59 
GeneralRe: Strange SQL Compact Problem - Vista Pin
Richard MacCutchan9-Jan-11 2:25
mveRichard MacCutchan9-Jan-11 2:25 
GeneralRe: Strange SQL Compact Problem - Vista Pin
TheComputerMan9-Jan-11 2:38
TheComputerMan9-Jan-11 2:38 
GeneralRe: Strange SQL Compact Problem - Vista Pin
Richard MacCutchan9-Jan-11 4:21
mveRichard MacCutchan9-Jan-11 4:21 
GeneralRe: Strange SQL Compact Problem - Vista Pin
TheComputerMan9-Jan-11 5:02
TheComputerMan9-Jan-11 5:02 
AnswerRe: Strange SQL Compact Problem - Vista Pin
Dave Kreskowiak8-Jan-11 4:25
mveDave Kreskowiak8-Jan-11 4:25 
GeneralRe: Strange SQL Compact Problem - Vista Pin
TheComputerMan8-Jan-11 16:30
TheComputerMan8-Jan-11 16:30 
AnswerRe: Strange SQL Compact Problem - Vista Pin
Luc Pattyn8-Jan-11 16:35
sitebuilderLuc Pattyn8-Jan-11 16:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.