次のようにsmthを実行できます(VBの場合):
Dim Str As String = ""
'Create File if doesn't exist
Dim FILE_NAME As String = "C:\temp\Custom.txt"
If System.IO.File.Exists(FILE_NAME) = False Then
System.IO.File.Create(FILE_NAME)
End If
Dim objWriter As System.IO.StreamWriter
Try
objWriter = New System.IO.StreamWriter(FILE_NAME)
Catch ex As System.IO.IOException
MsgBox("Please close the file: (C:\temp\Custom.txt) before proceeding" & vbCrLf & ex.Message.ToString, MsgBoxStyle.Exclamation)
objWriter = Nothing
Err = True
End Try
'I assume you know how to write to text file.
'Say my datagridview is named "dgrid"
Dim x,y as integer
For x = 0 to dgrid.rows.count -1
For y = 0 to dgrid.columns.count - 1
Str = dgrid.Rows(x).Cells(y).Values & " "
Next y
Next x
objWriter.Close()
リソース。
または、DataTable からCSVファイルを生成することもできます。