Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Abstract the FileDialog code to a separate method and pass in your version string so that you can then perform the checks.</p> <pre><code>public void OpenVersionDialog(string version) { string mcAD = GetCopyPath(version); if(!String.IsNullOrEmpty(mcAD)) { 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); File.Copy(item.FileName, mcAD, true); } } } else { //invalid version selected } } public string GetCopyPath(string versionInput) { //these are case-insensitive checks but you can change that if you want case-sensitive if(string.Equals(versionInput, "1.0 Selected", StringComparison.OrdinalIgnoreCase)) return "YOUR_PATH_FOR 1.0"; if(string.Equals(versionInput, "2.0 Selected", StringComparison.OrdinalIgnoreCase)) return "YOUR_PATH_FOR 2.0"; if(string.Equals(versionInput, "3.0 Selected", StringComparison.OrdinalIgnoreCase)) return "YOUR_PATH_FOR 3.0"; return String.Empty; } </code></pre> <p>If I understand correctly that should be what you want. If you have more versions, you could store them in a dictionary where the key is the version and the value is the path that the file should be copied to.</p> <p>I'm not sure what the difference between <code>mcAD</code> and <code>destPath</code> is but I assume <code>mcAD</code> is the variable that changes based on the version as that's being used in <code>File.Copy</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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