c# - 读取和写入文件

标签 c#

我有几个问题。是的,这是家庭作业,我只是想理解它。

这就是被问到的问题。

• When the button “Load” is clicked, read the file specified in the textbox (txtFilePath: Absolute path not relative) and add the objects found within to the listbox

• When the user clicks the “Save” button, write the selected record to the file specified in txtFilePath (absolute path not relative) without truncating the values currently inside

有人可以向我解释一下吗,因为我还在学习这个。我在那里有按钮和文本框,保存时也一样。现在使用保存按钮,我将拥有与您只想保存它时相同的代码。但是从我收集的信息来看,有一个数据库,因此您可以加载您保存的文件。还是我让它变得比实际更难了?

最佳答案

不,没有数据库。在这些说明中,record == some selected item 需要附加到现有文件。只需使用流和写入器将文件保存到磁盘即可满足要求。

关于c# - 读取和写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10284740/

相关文章:

c# - 带有 xs :anytype causing serialization problems 的 WCF 消息

c# - 在不使用免费的第三方解决方案的情况下在 ASP.NET 中压缩文件

c# - 在条件中使用赋值是否安全? C/C++、C#

c# - 将 DataGrid 绑定(bind)到 XmlDataProvider 时出现问题

c# - 生成表达式<>以按任意属性进行过滤

c# - 事件设计器中未启用 ReportViewer 控件。 - Visual Studio 2017

c# - Sharepoint 2013 中的联合身份验证 : getting rtFa and FedAuth cookies

c# - LINQ - .Select(n => n.Name) 和 .Select(n => new { n.Name } ) 之间的区别;

c# - 将非托管 native 库文件包含到 nuget 输出目录中

c# - 没有具有键 'IEnumerable<SelectListItem>' 的 'CicekListesi' 类型的 ViewData 项