這是我的C#代碼。設置保存C#文件的默認文件夾
但每次我運行此代碼時,每當我點擊左側單擊該文件被保存在默認路徑:「C:\ NewFolder \」
但我不知道如何設置使用選擇的文件夾右鍵點擊作爲我的默認文件夾永遠。
之後,我使用鼠標右鍵,每當我運行exe文件,選擇一個文件夾,該文件應在選定文件夾保存
string folderpath = "C:\\NewFolder\\";
private void button1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
bool exists = System.IO.Directory.Exists(folderpath);
if (!exists)
System.IO.Directory.CreateDirectory(folderpath);
this.Hide();
System.Threading.Thread.Sleep(1000);
SendKeys.Send("{PRTSC}");
Image img = Clipboard.GetImage();
img.Save(folderpath + "\\" + DateTime.Now.Ticks + ".jpg");
this.Show();
}
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
folderpath = folderBrowserDialog1.SelectedPath;
}
}
}
'Properties.Settings.Default.Folderpath = folderBrowserDialog1.SelectedPath;'以上代碼中的FolderPath是隻讀的。如何在運行時修改該值。 – satheesh
將設置類型更改爲用戶。 –
供您參考:http://stackoverflow.com/questions/758389/why-are-application-settings-read-only-in-app-config –