本文整理汇总了C#中System.Resources.ResourceReader.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceReader.ReadLine方法的具体用法?C# ResourceReader.ReadLine怎么用?C# ResourceReader.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resources.ResourceReader
的用法示例。
在下文中一共展示了ResourceReader.ReadLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public void Load(string fileName)
{
this.New();
this.FileName = fileName;
string fileExtension = Path.GetExtension(fileName).ToLower();
try
{
switch (fileExtension)
{
case ".xml":
case ".resx":
using (ResXResourceReader reader = new ResXResourceReader(fileName))
{
this.BeginUpdate();
Hashtable resources = new Hashtable();
IDictionaryEnumerator enumerator = reader.GetEnumerator();
while (enumerator.MoveNext())
{
string name = (string) enumerator.Key;
object value = enumerator.Value;
if (!resources.Contains(name))
{
this.AddResource(name, value);
resources.Add(name, value);
}
}
this.EndUpdate();
}
break;
case ".resources":
using (FileStream stream = File.OpenRead(fileName))
{
this.BeginUpdate();
using (ResourceReader reader = new ResourceReader(stream))
{
Hashtable resources = new Hashtable();
IDictionaryEnumerator enumerator = reader.GetEnumerator();
while (enumerator.MoveNext())
{
string name = (string)enumerator.Key;
object value = enumerator.Value;
if (!resources.Contains(name))
{
this.AddResource(name, value);
resources.Add(name, value);
}
}
}
this.EndUpdate();
}
break;
case ".txt":
using (StreamReader reader = File.OpenText(fileName))
{
this.BeginUpdate();
Hashtable resources = new Hashtable();
while (reader.Peek() != -1)
{
string line = reader.ReadLine();
line = line.TrimStart();
if (!line.StartsWith(";"))
{
int index = line.IndexOf("=");
if (index != -1)
{
string name = line.Substring(0, index);
string value = line.Substring(index + 1);
name = name.Trim();
if (!resources.Contains(name))
{
this.AddResource(name, value);
resources.Add(name, value);
}
}
}
}
this.EndUpdate();
}
break;
default:
MessageBox.Show(this, "Unknown resource file format.", StringTable.GetString("ApplicationName"));
break;
}
}
catch (Exception exception)
//.........这里部分代码省略.........