我有一个用随机值生成的数组。当我保存数组时,生成的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