简体   繁体   中英

Using Xamarin, how do I store data on a .csv file to local android storage?

例如,如果我有两个数组ArrayX和ArrayY中的数据,如何将数据写入本地android存储中的.csv文件中?

this assumes ArrayX & ArrayY are non-null and have the same number of elements

string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "myfile.csv");

using (StreamWriter sw = File.CreateText(path))
{
    for (int ndx = 0; ndx <= ArrayX.Length; ndx++)
    {
      sw.WriteLine(ArrayX[ndx] + "," + ArrayY[ndx]);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM