-3
我做了一個使用Writeline()更改.txt文件的程序。一切工作正常,只是我真的想知道是否有可能或不顯示寫作的進度,如果可能的話,如何。注意:我最近纔開始使用c#。如何使用WinForms中的進度條報告文件輸出進度?
private void button1_Click(object sender, EventArgs e)
{
string res = "";
{
if (checkBox1.Checked == true) { res = "playercontrols:1:up-w,right-d,left-a,aimy-,run-lshift,reload-r,portal2-,portal1-,jump- ,aimx-,down-s,use-e;playercontrols:2:up-joy-1-hat-1-u,right-joy-1-hat-1-r,left-joy-1-hat-1-l,aimy-joy-1-axe-4-neg,run-joy-1-but-3,reload-joy-1-but-4,portal2-joy-1-but-6,portal1-joy-1-but-5,jump-joy-1-but-1,aimx-joy-1-axe-5-neg,down-joy-1-hat-1-d,use-joy-1-but-2;playercontrols:3:up-joy-2-hat-1-u,right-joy-2-hat-1-r,left-joy-2-hat-1-l,aimy-joy-2-axe-4-neg,run-joy-2-but-3,reload-joy-2-but-4,portal2-joy-2-but-6,portal1-joy-2-but-5,jump-joy-2-but-1,aimx-joy-2-axe-5-neg,down-joy-2-hat-1-d,use-joy-2-but-2;playercontrols:4:up-joy-3-hat-1-u,right-joy-3-hat-1-r,left-joy-3-hat-1-l,aimy-joy-3-axe-4-neg,run-joy-3-but-3,reload-joy-3-but-4,portal2-joy-3-but-6,portal1-joy-3-but-5,jump-joy-3-but-1,aimx-joy-3-axe-5-neg,down-joy-3-hat-1-d,use-joy-3-but-2;playercolors:1:224,32,0,136,112,0,252,152,56;playercolors:2:255,255,255,0,160,0,252,152,56;playercolors:3:0,0,0,200,76,12,252,188,176;playercolors:4:32,56,236,0,128,136,252,152,56;portalhues:1:0,0.125;portalhues:2:0.25,0.375;portalhues:3:0.5,0.625;portalhues:4:0.75,0.875;mariohats:1:1;mariohats:2:1;mariohats:3:1;mariohats:4:1;scale:3;shader1:none;shader2:none;volume:1;mouseowner:1;mappack:smb;gamefinished;"; }
else { res = "playercontrols:1:up-w,right-d,left-a,aimy-,run-lshift,reload-r,portal2-,portal1-,jump- ,aimx-,down-s,use-e;playercontrols:2:up-joy-1-hat-1-u,right-joy-1-hat-1-r,left-joy-1-hat-1-l,aimy-joy-1-axe-4-neg,run-joy-1-but-3,reload-joy-1-but-4,portal2-joy-1-but-6,portal1-joy-1-but-5,jump-joy-1-but-1,aimx-joy-1-axe-5-neg,down-joy-1-hat-1-d,use-joy-1-but-2;playercontrols:3:up-joy-2-hat-1-u,right-joy-2-hat-1-r,left-joy-2-hat-1-l,aimy-joy-2-axe-4-neg,run-joy-2-but-3,reload-joy-2-but-4,portal2-joy-2-but-6,portal1-joy-2-but-5,jump-joy-2-but-1,aimx-joy-2-axe-5-neg,down-joy-2-hat-1-d,use-joy-2-but-2;playercontrols:4:up-joy-3-hat-1-u,right-joy-3-hat-1-r,left-joy-3-hat-1-l,aimy-joy-3-axe-4-neg,run-joy-3-but-3,reload-joy-3-but-4,portal2-joy-3-but-6,portal1-joy-3-but-5,jump-joy-3-but-1,aimx-joy-3-axe-5-neg,down-joy-3-hat-1-d,use-joy-3-but-2;playercolors:1:224,32,0,136,112,0,252,152,56;playercolors:2:255,255,255,0,160,0,252,152,56;playercolors:3:0,0,0,200,76,12,252,188,176;playercolors:4:32,56,236,0,128,136,252,152,56;portalhues:1:0,0.125;portalhues:2:0.25,0.375;portalhues:3:0.5,0.625;portalhues:4:0.75,0.875;mariohats:1:1;mariohats:2:1;mariohats:3:1;mariohats:4:1;scale:3;shader1:none;shader2:none;volume:1;mouseowner:1;mappack:smb;"; }
if (checkBox2.Checked == true) { res = res + "reachedworlds:smb:1,"; }
else { res = res + "reachedworlds:smb:0,"; }
if (checkBox3.Checked == true) { res = res + "1,"; }
else { res = res + "0,"; }
if (checkBox4.Checked == true) { res = res + "1,"; }
else { res = res + "0,"; }
if (checkBox5.Checked == true) { res = res + "1,"; }
else { res = res + "0,"; }
if (checkBox6.Checked == true) { res = res + "1,"; }
else { res = res + "0,"; }
if (checkBox7.Checked == true) { res = res + "1,"; }
else { res = res + "0,"; }
if (checkBox8.Checked == true) { res = res + "1,"; }
else { res = res + "0,"; }
if (checkBox9.Checked == true) { res = res + "1;"; }
else { res = res + "0;"; }
}
DialogResult ans=MessageBox.Show("Warning! All settings in your game will be reset. Do you wish to continue?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (ans == DialogResult.OK)
{
string roaming = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string path = roaming + "\\LOVE\\mari0\\options.txt";
using (StreamWriter sr = new StreamWriter(path))
{
sr.Write(res);
}
}
你是否使用過Google搜索,並找到了[如何使用WinForms進度條?](http://stackoverflow.com/questions/12126889/how-to-use-winforms-progress-bar) – user1477388
請再考慮一下你的問題的標題。它應是問題/問題的*摘要*,而不是大多數隨機的單詞集合。 –
重新思考標題後,問問自己寫入文件的數據量以及通常需要多少時間。 ...你確定你需要一個進度條嗎? –