问题描述
我有一个用随机值生成的数组。当我保存数组时,生成的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
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)