Bra*_*ble 3 c# file embedded-resource
如果可以从源文件中读取,如下所示:
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];
}
}
Run Code Online (Sandbox Code Playgroud)
那你怎么写同一个文件?
您可以使用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();
}
}
Run Code Online (Sandbox Code Playgroud)