gpt4 book ai didi

c# - 如何写入资源文件?

转载 作者:行者123 更新时间:2023-11-30 13:50:47 27 4
gpt4 key购买 nike

如果可以像这样从源文件中读取:

string fileContent = Resources.Users;

using (var reader = new StringReader(fileContent))
{
string line;
while ((line = reader.ReadLine()) != null)
{
string[] split = line.Split('|');
string name = split[0];
string last = split[1];

}
}

那你怎么写同一个文件呢?

最佳答案

您可以使用 ResourceWriter .我还建议您使用 ResourceManager从文件中读取。

来自链接源的代码:

using System;
using System.Resources;

public class WriteResources {
public static void Main(string[] args) {

// Creates a resource writer.
IResourceWriter writer = new ResourceWriter("myResources.resources");

// Adds resources to the resource writer.
writer.AddResource("String 1", "First String");

writer.AddResource("String 2", "Second String");

writer.AddResource("String 3", "Third String");

// Writes the resources to the file or stream, and closes it.
writer.Close();
}
}

关于c# - 如何写入资源文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5599662/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com