c#中怎么样写入或读取运行wince5.0系统的便携设备中文件
展开全部
//运行EXE
Process.Start("\\NandFlash\\XXX.exe", "");//XXX.exe 要运行的程序
//写文件(同理可写任何文件)
private void button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("\\NandFlash\\XXX.txt", FileMode.Create);
StreamWriter sw = new StreamWriter(fs, Encoding.Default);
string str = "写入我";
sw.WriteLine(str);
sw.Close();
fs.Close();
}
//读文件
try
{
FileStream fs = new FileStream("\\NandFlash\\XXX.txt", FileMode.Open, FileAccess.ReadWrite);
StreamReader readfile = new StreamReader(fs);
byte[] strs = new byte[2048];
string str, ss = "";
int index = 0;
while (readfile.EndOfStream == false)
{
str = readfile.ReadLine();
ss = str.Trim();
strs[index] = Convert.ToSingle(ss);
index += 1;
ss = "";
}
readfile.Close();
fs.Close();
return 0;
}
catch
{
return 1;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询