110,536
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Text;
namespace MyNewsReader
{
class Profile
{
public Profile() { }
//频道集合
public List<FeedBase> Feeds = new List<FeedBase>();
//刷新间隔
public TimeSpan IntervalToRefresh;
}
}
class ProfileManager
{
public Profile Profile = new Profile();
public ProfileManager()
{
//Init();
}
//默认频道设置
private void ChannelReset()
{
Profile.Feeds.Clear();
}
//保存用户配置信息
public void Save()
{
FileStream fs = new FileStream("user.profile",FileMode.Create);//文件流的参数应该是(string path,FileMode Mode)
StreamWriter sw = new StreamWriter(fs);
//写入频道总数
sw.WriteLine(Profile.Feeds.Count);
foreach(FeedBase feed in Profile.Feeds)
{
////判断频道类型
if (feed is AtomFeed)
{
sw.WriteLine("Atom");//写入频道类型
}
if (feed is RssFeed)
{
sw.WriteLine("RSS");
}
//Feed 的三个基本信息每行存一个
sw.WriteLine(feed.DisplayName);
sw.WriteLine(feed.Url);
sw.WriteLine(feed.Description);
}
sw.Close();
fs.Close();
}