社区
C#
帖子详情
急!急!急!! c#读取properties类型文件
jiaozi123
2007-01-10 09:18:11
java中有专门的类读取properties类型文件: Properties
请问c#中有没有类似的专门类
...全文
440
7
打赏
收藏
急!急!急!! c#读取properties类型文件
java中有专门的类读取properties类型文件: Properties 请问c#中有没有类似的专门类
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
机器人
2007-01-11
打赏
举报
回复
static void Main(string[] args)
{
string strFileName = "E:\\Visual Studio Project\\MessageResources.properties";
Console.WriteLine(GetPropertiesText(strFileName));
Console.Read();
}
public static string GetPropertiesText(string strFileName)
{
StringBuilder sb = new StringBuilder();
using(StreamReader sr = new StreamReader(strFileName))
{
string str = null;
while ((str = sr.ReadLine()) != null)
{
Regex regex = new Regex("(\\\\u[A-F0-9]{4})");
if(regex.IsMatch(str))
{
foreach(Match m in regex.Matches(str))
{
str = str.Replace(m.Result("$1"), GetUnicodeString(m.Result("$1").Replace("\\u", "")));
}
sb.Append(str);
}
else
{
sb.Append(str);
}
sb.Append("\n");
}
}
return sb.ToString();
}
public static string GetUnicodeString(string strInput)
{
try
{
byte[] array = new byte[2];
string str = strInput;
string s1 = str.Substring(0, 2);
string s2 = str.Substring(2);
array[0] = Convert.ToByte(s1, 16);
array[1] = Convert.ToByte(s2, 16);
return System.Text.Encoding.BigEndianUnicode.GetString(array);
}
catch(Exception e)
{
return strInput;
}
}
jiaozi123
2007-01-10
打赏
举报
回复
明天就得实现阿大哥,有没有代码参照一下,急死我了阿!!!!
lizhizhe2000
2007-01-10
打赏
举报
回复
MSDN
Ivony
2007-01-10
打赏
举报
回复
请参阅:
System.Configuration命名空间。
jiaozi123
2007-01-10
打赏
举报
回复
具体说说
CMIC
2007-01-10
打赏
举报
回复
反射,System.Reflection名字空间下的类
jiaozi123
2007-01-10
打赏
举报
回复
求各位大哥们帮忙啊!!!
c#
操作
properties
,读写配置
文件
c#
操作
properties
,读写配置
文件
,非常方便,几行代码就搞定
Properties
文件
的
读取
与保存
Properties
文件
的
读取
与保存
C#
文件
系统的操作
本课程将介绍如何在
C#
中执行读写
文件
操作,读写
文件
夹操作。
C#
读取
properties
文件
java中有
读取
*.
properties
的专有类,
C#
中却没能找到.今天写了一个基本的Class,并解决了hashtable中按照读的顺序输出问题,供大家参考. /// /// 类名:File
Properties
/// 描述:操作*.
Properties
文件
/// 作者:Michael /// 创建时间:2008-03-11 /// public c
C#
读写
Properties
配置
文件
C#
读写
Properties
文件
本来想在项目里
读取
和写入一些配置数据。一番探索后,INI
文件
需要引用API;XML的层次结构用不着,也麻烦。 这时想到Java的
Properties
配置
文件
挺方便,格式类似于INI,自己动手写一个。 using System; using System.IO; using System.Text; using System.Collections;...
C#
110,535
社区成员
642,577
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章