我想在我的程序中加一个登录窗口,第一次想在ini配置文件中给写入一个默认的用户名、密码 如“123”、“123”,在第一次登录窗口的时候提醒用户登陆的默认密码,在登录窗口旁边有个修改密码的按钮,点击弹出一个修改密码的窗口,再将修改后的密码和用户名写入ini文件中,之后用户登录要用到新的用户名和密码。
我是一名初学者,看了许多的 ini文件的读写的文章,但是看不懂,将代码写入总是出错,我不知道为什么?请大家帮帮我
最好给我一个详细的实例
下面的代码我想把默认的用户名和密码写进去,但是出错,写不下去了。
是不是要预先在Debug 里面先新建一个ini文件啊?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
namespace 测绘
{
public partial class Form1 : Form
{
public string Path;
//类的构造函数,传递INI文件名
public
IniFile(string inipath)
//在这里提示IniFile 必须要有返回值类型
{
//
// TODO: Add constructor logic here
//
Path = inipath;
}
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,string key, string def, StringBuilder retVal,int size, string filePath);
static string str = Application.StartupPath + "\\ConnectString.ini";
static string strOne = System.IO.Path.GetFileNameWithoutExtension(str);
if
(File.) //在这里File.后面没有Exsis 函数
public Form1()
{
InitializeComponent();
}