enter image description here这个登录系统工作正常..但我需要更改路径作为默认值..目前它'保存在'C'驱动器..可以保存在调试文件夹内。有可能吗?
try
{
var sr = new System.IO.StreamReader("C:\\" + textBox1.Text + "\\login.ID");
username = sr.ReadLine();
password = sr.ReadLine();
sr.Close();
if (username == textBox1.Text && password == txtPass.Text)
{
MessageBox.Show("You are now successfully logged in |Welcome", "Success");
frmMainMenu frm = new frmMainMenu();
frm.Show();
this.Hide();
}
else
{
MessageBox.Show("User Name Or Password Wrong!", "Error");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
答案 0 :(得分:1)
var currentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);