服务器报信息错误,第一次运行保持服务器信息报IO错误问题处理

第一次运行,当没有WinRemoteDesktop.db时,新建远程会如下错误:

![输入图片说明](https://images.gitee.com/uploads/images/2020/1020/112847_f118cdfb_1716151.png "屏幕截图.png")

我对TXTClass().txtRead(string filepath, char split)方法进行了代码进行了优化:

```

///

/// 读取txt文件内容,读取结果以DataTable(列名分别为c0,c1,c2,c3,... ...)形式返回

///

/// txt文件每一行中不同列之间的分隔符

///

public DataTable txtRead(string filepath, char split)

{

DataTable table = new DataTable();

try

{

string str2;

this.FileNotExistAndCreate(filepath);

FileStream stream = new FileStream(filepath, FileMode.Open, FileAccess.Read);

StreamReader reader = new StreamReader(stream);

reader.BaseStream.Seek(0L, SeekOrigin.Begin);

string str = reader.ReadLine();

if (!String.IsNullOrWhiteSpace(str))

{

int length = str.Split(new char[] { split }).Length;

for (int i = 0; i < length; i++)

{

str2 = "c" + i.ToString();

table.Columns.Add(str2, typeof(string));

}

while ((str != null) && (str != ""))

{

string[] strArray2 = str.Split(new char[] { split });

DataRow row = table.NewRow();

for (int j = 0; j < length; j++)

{

str2 = "c" + j.ToString();

row[str2] = strArray2[j];

}

table.Rows.Add(row);

table.AcceptChanges();

str = reader.ReadLine();

}

}

reader.Close();

stream.Close();

}

catch (Exception exception)

{

string text = exception.ToString();

if (exception.InnerException != null)

{

text = text + exception.InnerException.ToString();

}

if (exception.StackTrace != null)

{

text = text + exception.StackTrace.ToString();

}

MessageBox.Show(text);

}

return table;

}

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值