06/03/12 17:53
blasters
Ciao a tutti,
vorrei convertire delle mie immagini in byte tipo questi 0xff,0xff,0xff,0xff,0xff per poi farli uscire in una textbox e utilizzarli in una seconda applicazione
ho trovato degli algoritmi ma come risultato ho sempre System.Byte[]
il codice da me utilizzato è il seguente
Dove sbaglio?
Grazie
vorrei convertire delle mie immagini in byte tipo questi 0xff,0xff,0xff,0xff,0xff per poi farli uscire in una textbox e utilizzarli in una seconda applicazione
ho trovato degli algoritmi ma come risultato ho sempre System.Byte[]
il codice da me utilizzato è il seguente
Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = ConvertImageFiletoBytes("C:\ciao.jpg").ToString End Sub Public Function ConvertImageFiletoBytes(ByVal ImageFilePath As String) As Byte() Dim _tempByte() As Byte = Nothing If String.IsNullOrEmpty(ImageFilePath) = True Then Throw New ArgumentNullException("Image File Name Cannot be Null or Empty", "ImageFilePath") Return Nothing End If Try Dim _fileInfo As New IO.FileInfo(ImageFilePath) Dim _NumBytes As Long = _fileInfo.Length Dim _FStream As New IO.FileStream(ImageFilePath, IO.FileMode.Open, IO.FileAccess.Read) Dim _BinaryReader As New IO.BinaryReader(_FStream) _tempByte = _BinaryReader.ReadBytes(Convert.ToInt32(_NumBytes)) _fileInfo = Nothing _NumBytes = 0 _FStream.Close() _FStream.Dispose() _BinaryReader.Close() Return _tempByte Catch ex As Exception Return Nothing End Try End Function End Class
Dove sbaglio?
Grazie
aaa