有没有办法将CSVHelper CSVWriter与Dropbox一起使用?
我以前曾使用过Dropbox,但读取文件。现在,我想编写一个文件,并发现这并不是那么简单。 ie this code, with FolderPath as relative to the Dropbox root folder...
using (StreamWriter writer=new StreamWriter(${FolderPath}MyCSVFile.csv"))
using (CsvWriter csv=new CsvWriter(writer,leaveOpen:false)) {csv.WriteRecords(records);}
Treats the path as relative to the device's root folder.使用读取很容易做到这一点,因为dropbox readfile返回字符串,因此所有csvhelper See都是字符串,但是在这种情况下,需要写入由Dropbox控制的位置,这意味着必须使用Dropbox Client。
我弄清楚了如何做到这一点,但是根据建议“分享您的知识Q&一种样式”,我将继续前进并为遇到此遇到的其他任何人回答自己的问题...
I've used CSVHelper with Dropbox previously, but reading files. Now I want to write a file, and have discovered that this is not so simple. i.e. this code, with FolderPath as relative to the Dropbox root folder...
using (StreamWriter writer=new StreamWriter(${FolderPath}MyCSVFile.csv"))
using (CsvWriter csv=new CsvWriter(writer,leaveOpen:false)) {csv.WriteRecords(records);}
Treats the path as relative to the device's root folder. It's easy to do this with read, because the Dropbox ReadFile returns a string, so all CSVHelper sees is a string, but in this case need to write to a location controlled by Dropbox, which means having to use the Dropbox client.
I worked out how to do it, but as per the suggestion "share your knowledge Q&A style", I'll keep going and answer my own question for anyone else who runs into this...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在键入我的问题时,我认为“如果只有一种方法可以将其作为字符串而不是写入设备”,但是CSVHelper DOCO仅使用StreamWriter向设备显示写作。因此,我决定只单击其他一些写作方案,然后在我可以使用stringwriter的“写入动态对象”中(我都不想看在那里,因为我曾经想过。与动态对象一起工作!)。
因此,这是我的工作代码(tempsb2是我在整个代码中重复使用的StringBuilder)...
Whilst typing my question, I thought "if only there was a way to get this as a string instead of writing to device", but the CSVHelper doco only showed writing to device, using StreamWriter. So I decided to just click around some of the other Write scenario's, and in the "writing to a Dynamic object" I found in that example that you could use StringWriter instead (I wouldn't have thought to look in there, since I wasn't working with Dynamic objects!).
So here is my working code (TempSB2 is a StringBuilder that I re-use throughout the code)...