Note that there are some explanatory texts on larger screens.

plurals
  1. POIf/Else with C#
    text
    copied!<p>Okay, so I'm working with some if/else statements now. But, I'm having some trouble. </p> <p>Here's the full code that is depending on the version clicked.</p> <pre><code>private void button_Click(object sender, EventArgs e) { using (OpenFileDialog file = new OpenFileDialog()) { file.Filter = "File(*.file)|*.jar|All Files (*.*)|*.*"; file.Title = "Open File..."; if (file.ShowDialog() == DialogResult.OK) { string fullFileName = item.FileName; FileInfo userSelected = new FileInfo(fullFileName); string fileNameWithExt = Path.GetFileName(fullFileName); string destPath = Path.Combine(Application.UserAppDataPath, fileNameWithExt); string mcAD = Environment.ExpandEnvironmentVariables("%AppData%"); File.Copy(item.FileName, mcAD, true); } } </code></pre> <p>But what I'm having trouble is with this. Below is the code, but here's how the program is lain out. There's a menu at the bottom of the program. It's named "Version" you click and you can choose version 1.0, 2.0, and 3.0. I have it set so there's text beside it telling it which version you chose. Now, the issue is I need an if/else statement for all the version for the above code cause all files for each version go to a different location.</p> <p>Here's the other code...</p> <pre><code>private void Version_1_0_Click(object sender, EventArgs e) { string Version_1_0_Selected = VersionText.Text = "1.0 Selected"; } private void Version_1_6_1_Click(object sender, EventArgs e) { string Version_2_0_Selected = VersionText.Text = "2.0 Selected"; } private void Version_3_0_Click(object sender, EventArgs e) { string Version_3_0_Selected = VersionText.Text = "3.0 Selected"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload