There are 6 most normal streams, but I need to save each stream in txt. When I write, then an error pops up that the file is already in use.
How to be, if you still need to save?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Threading; using System.Threading.Tasks; namespace Threads { class Program { private static void Save(string data) { StreamWriter writer = new StreamWriter("C:/Users/Wiz/Desktop/test.txt", true, Encoding.GetEncoding("windows-1251")); writer.Write(data + Environment.NewLine); writer.Close(); } static string str = "abcdefghijklmnopqrstuvwxyz"; static void Main(string[] args) { Thread th1 = new Thread(thread1); th1.Start(); Thread th2 = new Thread(thread2); th2.Start(); Thread th3 = new Thread(thread3); th3.Start(); Thread th4 = new Thread(thread4); th4.Start(); Thread th5 = new Thread(thread5); th5.Start(); Thread th6 = new Thread(thread6); th6.Start(); } static void thread1() { for (int a = 0; a < str.Length; a++) { for (int b = 0; b < str.Length; b++) { for (int c = 0; c < str.Length; c++) { for (int d = 0; d < str.Length; d++) { string s111 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d].ToString(); Console.WriteLine(s111); Save(s111); } } } } } static void thread2() { for (int a = 0; a < str.Length; a++) { for (int b = 0; b < str.Length; b++) { for (int c = 0; c < str.Length; c++) { for (int d = 0; d < str.Length; d++) { string s111 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d].ToString(); Console.WriteLine(s111); Save(s111); } } } } } static void thread3() { for (int a = 0; a < str.Length; a++) { for (int b = 0; b < str.Length; b++) { for (int c = 0; c < str.Length; c++) { for (int d = 0; d < str.Length; d++) { string s111 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d].ToString(); Console.WriteLine(s111); Save(s111); } } } } } static void thread4() { for (int a = 0; a < str.Length; a++) { for (int b = 0; b < str.Length; b++) { for (int c = 0; c < str.Length; c++) { for (int d = 0; d < str.Length; d++) { string s111 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d].ToString(); Console.WriteLine(s111); Save(s111); } } } } } static void thread5() { for (int a = 0; a < str.Length; a++) { for (int b = 0; b < str.Length; b++) { for (int c = 0; c < str.Length; c++) { for (int d = 0; d < str.Length; d++) { string s111 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d].ToString(); Console.WriteLine(s111); Save(s111); } } } } } static void thread6() { for (int a = 0; a < str.Length; a++) { for (int b = 0; b < str.Length; b++) { for (int c = 0; c < str.Length; c++) { for (int d = 0; d < str.Length; d++) { string s111 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d].ToString(); Console.WriteLine(s111); Save(s111); } } } } } } }