本文介绍了从十六进制转换回正常并将文件结果保存为OutOfMemory Exception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在vb.net中创建一个程序,它的作用是当你打开一个文件时它会把文件打开成十六进制代码,但问题是如果我保存一个文件是大,它通常导致OutOfMemory异常。

尝试
Dim b As Byte()= RichTextBox1 .Text.Split("" c).Select(Function(n)Convert.ToByte(Convert.ToInt32(n,16)))
My.Computer.FileSystem.WriteAllBytes(SaveFileDialog1.FileName,b,错误)
Catch ex1 As Exception
尝试
Dim b As Byte()= RichTextBox1.Text.Split("" c).Select(Function(n)Convert.ToByte(Convert .ToInt32(n,16)))
My.Computer.FileSystem.WriteAllBytes(OpenFileDialog1.FileName,b,False)
Catch ex As Exception
MsgBox(" Exception caught:" + vbNewLine + vbNewLine + ex.ToString,MsgBoxStyle.Critical," Exception Error")
结束尝试
结束尝试



Lloyd .CH。

解决方案

I'm trying to make a program in vb.net and what it does is that when you open a file it turns the file opened into hexadecimal code, but the problem is that if I save a file that is large, It usually results in a OutOfMemory Exception.

            Try
        Dim b As Byte() = RichTextBox1.Text.Split(" "c).Select(Function(n) Convert.ToByte(Convert.ToInt32(n, 16)))
        My.Computer.FileSystem.WriteAllBytes(SaveFileDialog1.FileName, b, False)
    Catch ex1 As Exception
        Try
            Dim b As Byte() = RichTextBox1.Text.Split(" "c).Select(Function(n) Convert.ToByte(Convert.ToInt32(n, 16)))
            My.Computer.FileSystem.WriteAllBytes(OpenFileDialog1.FileName, b, False)
        Catch ex As Exception
            MsgBox("Exception caught : " + vbNewLine + vbNewLine + ex.ToString, MsgBoxStyle.Critical, "Exception Error")
    End Try
    End Try

Lloyd .CH.

解决方案


这篇关于从十六进制转换回正常并将文件结果保存为OutOfMemory Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 10:53