【发布时间】:2018-07-24 13:43:27
【问题描述】:
我希望保存 XML 文件的路径,并在程序重新打开时使用 Winforms 上的按钮加载它。我已经环顾了一下保存状态,但到目前为止似乎没有什么可以减少芥末。 下面是我的代码
private void Form1_Load(object sender, EventArgs e)
{
//Loading of the form
}
private void btnOpen_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog fbd = new FolderBrowserDialog() { Description="Select your folder"})
{
if (fbd.ShowDialog() == DialogResult.OK)
webBrowser.Url = new Uri(fbd.SelectedPath);
txtPath.Text = fbd.SelectedPath;
// Button used to open the folder explorer and display file path in the text box.
}
}
private void btnBack_Click(object sender, EventArgs e)
{
if (webBrowser.CanGoBack)
webBrowser.GoBack(); //Sends the explorer back one page providing there is a page to go back too
}
private void btnForward_Click(object sender, EventArgs e)
{
if (webBrowser.CanGoForward)
webBrowser.GoForward(); //Sends the explorer forward one page providing there is a page to go forward too
}
private void btnSave_Click(object sender, EventArgs e)
{
}
private void txtPath_TextChanged(object sender, EventArgs e)
{
}
}
The save search is what I want to use to store the users chosen path.
【问题讨论】:
-
您的
btnSave_Click方法没有代码;这可能是问题吗? -
我是初学者,这是我的问题,我无法理解该方法的逻辑是什么:)
-
看看这个:google.com/…
-
感谢大家的帮助,问题已经解决,程序正在按照我想要的方式运行!
标签: c# xml winforms file explorer