public static CopyAmountInterface GetCopyAmountTool() { if (tool == null) { tool = new CopyAmountImpl(); } return(tool); }
private void button1_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); textBox1.Text = folderBrowserDialog1.SelectedPath; // 工厂模式 CopyAmountInterface copyAmount = FactoryCopyAmountTool.GetCopyAmountTool(); FileInfo[] f = copyAmount.fileInfos(textBox1.Text); for (int i = 0; i < f.Length; i++) { listBox1.Items.Add(f[i]); } }