我有一个将数据编译在一起的网络服务,我想将其存储在 CSV 中,以便用户可以获得下载链接来获取它。这就是我所拥有的
string fileName = "Test.csv";
string ftpAddress = "MYDOMAIN.COM";
string username = "MYUSERNAME";
string password = "MYPASSWORD";
List<string[]> done = new List<string[]>();
string[] firstline = new string[2];
firstline[0] = "hello this is ";
firstline[1] = "a test";
done.Add(firstline);
string[] secondline = new string[2];
secondline[0] = "hello this is a ";
secondline[1] = "second test";
done.Add(secondline);
string delimiter = ",";
StringBuilder sb = new StringBuilder();
for (int index = 0; index < 2; index++)
sb.AppendLine(string.Join(delimiter, done[index]));
string str = sb.ToString();
byte[] buffer = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, buffer, 0, buffer.Length);
WebRequest request = WebRequest.Create("ftp://" + ftpAddress + fileName);
request.ContentType =
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
CSV 保存正确,但我没有得到它读取的单独列
“你好这是一个测试”
“你好这是一个第二个测试”
而不是
"你好这是","一个测试"
"你好这是一个","第二个测试"
关于如何让逗号分隔列的任何想法?