简体   繁体   English

如何在UWP vb.net中写入.txt文件

[英]how to write to .txt file in UWP vb.net

i am trying to have a .txt file containing a single line with a number on it. 我试图有一个.txt文件,其中包含一行并带有数字。 i need this txt file to be editable by the program and to be installed with it. 我需要此txt文件由程序进行编辑并与之一起安装。 the .txt file will be completely overwritten when the number needs to be replaced. 需要替换数字时,.txt文件将被完全覆盖。

how can i do this? 我怎样才能做到这一点? all other tutorials refer to C# or JS I need vb.NET 所有其他教程都引用C#或JS,我需要vb.NET

Read this Create, write, and read a file topic about interaction with file in UWP . 阅读此创建,编写和阅读文件主题,了解如何与UWP 的文件交互。

To write string to StorageFile use FileIO.WriteTextAsync or FileIO.AppendTextAsync functions 要将字符串写入StorageFile使用FileIO.WriteTextAsyncFileIO.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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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