C# 菜鸟继续提问! - .NET技术 / C#
做个小东西,运行过程中会得到一个int数据,我想把这个数据另存为问题,下次该程序再运行时可以使用!XML,TXT等都行!怎么生成,生成了怎么更新,怎么读取!相对路径!
你放到本地的一个txt文件里,程序关闭时把该文件打开,更新,程序开启式打开读取
如果就只有个数据的话,那就存个txt吧。
web:
写:
using (StreamWriter sw = File.CreateText(Server.MapPath(相对路径)))
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
}
读:
using (StreamReader sr = File.OpenText(Server.MapPath(相对路径)))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
up
关闭时更新
C# code:
// it will be done when the form close.
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
FileStream file = File.Open(@"C:\dataBegin.txt", FileMode.Open);
StreamWriter sWriter = new StreamWriter(file);
//change the record in the file.
sWr
相关问答:
写了个测试程序如下
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
#include"stdio.h"
#include"stdlib.h"
void ContrTwo(char i)
{
char str1[8];
itoa(i,str1,2);
printf("%s",str1);
}
unsigned char leftRot(char str,int i);
unsign ......
我这里有一个登陆WIFI网络的页面。由于WIFI经常断线,所以要反复地在这个网页上登陆,没法无人值守。
所以,我想做一个C#程序,放一个webbrowser控件,自动填表并自动点击提交按钮。
问题一:
基本照网上找的程序 ......
以下是一段JavsScript脚本,但运行时总会产生 “Microsoft JScript 运行时错误: 'null' 为空或不是对象”异常,大家帮看一下。
<form id="form1" runat="server">
< ......
我们C#做一个窗体 往数据库里插入数据
SqlConnection cn = new SqlConnection("Data Source=20090713-1752\\SQLEXPRESS;Initial Catalog=goods;Integrated Security=True");
......