Public Function ConvertFiletoBytes(ByVal FilePath As String) As Byte()
Dim _tempByte() As Byte = Nothing
If String.IsNullOrEmpty(FilePath) = True Then
Throw New ArgumentNullException("File Name Cannot be Null or Empty", "FilePath")
Return Nothing
End If
Try
Dim _fileInfo As New IO.FileInfo(FilePath)
Dim _NumBytes As Long = _fileInfo.Length
Dim _FStream As New IO.FileStream(FilePath, 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
Public Function ConvertBytesToFile(ByVal FilePath As String, ByVal fileData As Byte()) As Boolean
If IsNothing(fileData) = True Then
Return False
End If
Try
Dim fs As IO.FileStream = New IO.FileStream(FilePath, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
Dim bw As IO.BinaryWriter = New IO.BinaryWriter(fs)
bw.Write(fileData)
bw.Flush()
bw.Close()
fs.Close()
bw = Nothing
fs.Dispose()
Return True
Catch ex As Exception
Return False
End Try
End Function
queste sono le funzioni in cui mi da errore