저는 C# 프로그램을 만들고 있습니다. 이 프로그램에서는 텍스트 상자의 값을 CSV 파일에 쓰려고합니다. 이것은 지금까지 작동합니다.C# 쓰기/읽기 CSV
hellobye|
hello (TextBox1)
bye (TextBox2)
언제나 새 줄을 맺을 수있는 방법은 무엇입니까? 벌써 환경을 시험해 봤어 .NewLine, 그냥 일하는 게 아니야. 이것은 지금까지 내 코드입니다
는:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length != 0)
{
String input = textBox1.Text + textBox2.Text;
string[] lines = {input + "|" };
System.IO.File.AppendAllLines(@"c:\output.csv", lines);
textBox1.Clear();
textBox2.Clear();
}
}
}
}
CSV는 * 쉼표로 구분 된 값을 의미합니다. * Pipe *를 구분 기호로 사용하려고합니다. –
그리고 당신의 결과는 당신이 말한 그대로입니다. 다른 것을 원한다면 다른 것을 말해야합니다. –
Dan-o, 네가하는 말은 어때? 내가 어떻게 .. 이해가 안 돼 입력은 내 CSV 파일에 새 줄에 있어야합니다. – haassiej