【问题标题】:how to write to .txt file in UWP vb.net如何在 UWP vb.net 中写入 .txt 文件
【发布时间】:2017-06-01 23:31:48
【问题描述】:
我正在尝试创建一个 .txt 文件,其中包含一行带有数字的行。我需要这个 txt 文件可以被程序编辑并与它一起安装。
当需要替换数字时,.txt 文件将被完全覆盖。
我该怎么做?所有其他教程参考 C# 或 JS 我需要 vb.NET
【问题讨论】:
标签:
.net
vb.net
uwp
text-files
【解决方案1】:
阅读此Create, write, and read a file 主题,了解与UWP 中的文件交互。
要将字符串写入StorageFile,请使用FileIO.WriteTextAsync 或FileIO.AppendTextAsync 函数
Dim file As StorageFile = Await ApplicationData.Current.LocalFolder.CreateFileAsync("file.txt", CreationCollisionOption.ReplaceExisting)
Dim strData As String = "sample text to write"
Await FileIO.WriteTextAsync(file, strData)