Arrays 保存数组并再次读取

Arrays 保存数组并再次读取,arrays,vb.net,file,save,savefiledialog,Arrays,Vb.net,File,Save,Savefiledialog,我有一个随机值生成的数组。当我保存数组时,生成的txt文件中只填充了System.String[,],而不是我试图保存的值。我该如何解决这个问题 Dim strFileName As String = String.Empty 'Set the Save dialog properties With SaveFileDialog1 .DefaultExt = "txt" .Filter = "Text Document

我有一个随机值生成的数组。当我保存数组时,生成的txt文件中只填充了System.String[,],而不是我试图保存的值。我该如何解决这个问题

Dim strFileName As String = String.Empty
    'Set the Save dialog properties
    With SaveFileDialog1
        .DefaultExt = "txt"
        .Filter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*"
        .FilterIndex = 1
        .OverwritePrompt = True
        .Title = "Save File"
    End With
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK And SaveFileDialog1.FileName <> String.Empty Then
        Try
            'Save the file path and name
            strFileName = SaveFileDialog1.FileName

            SaveFile(strFileName, valuein)

        Catch ex As Exception
            MessageBox.Show(ex.Message, My.Application.Info.Title,
              MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End If
End Sub
Sub SaveFile(ByVal path As String, ByVal textToSave As String)

    Dim strmWriter As New System.IO.StreamWriter(path, False) 'false = don't append to an existing file
    For Each i In Value
        strmWriter.Write(Value)
    Next
    'strmWriter.Write(textToSave)

    strmWriter.Close()
    strmWriter.Dispose()
    'Show the file using the default text file viewer ( probably Notepad will show ).>>
    System.Diagnostics.Process.Start(path)

End Sub
Dim strFileName As String=String.Empty
'设置保存对话框属性
使用SaveFileDialog1
.DefaultExt=“txt”
.Filter=“文本文档(*.txt)|*.txt |所有文件(*.*)|*.”
.FilterIndex=1
.OverwritePrompt=True
.Title=“保存文件”
以
如果SaveFileDialog1.ShowDialog=Windows.Forms.DialogResult.OK和SaveFileDialog1.FileName String.Empty,则
尝试
'保存文件路径和名称
strFileName=SaveFileDialog1.FileName
保存文件(strFileName,valuein)
特例
MessageBox.Show(例如Message、My.Application.Info.Title、,
MessageBoxButtons.OK,MessageBoxIcon.Error)
结束尝试
如果结束
端接头
子保存文件(ByVal路径作为字符串,ByVal文本作为字符串保存)
Dim strmWriter As New System.IO.StreamWriter(path,False)'False=不附加到现有文件
对于每一个i值
strmWriter.Write(值)
下一个
'strmWriter.Write(textToSave)
strmWriter.Close()
strmWriter.Dispose()
'使用默认文本文件查看器显示文件(可能记事本会显示)。>>
系统.诊断.过程.启动(路径)
端接头

为strmWriter中的每个i值编写(i)Next
如果您有
字符串
数组,只需调用
File.writeAllines来保存它即可。然后可以通过调用
File.ReadAllLines
加载。每个方向一行代码。天哪,我是个白痴。非常感谢。