Я хочу записать номера всех номеров банков в фактический файл. Не консольная версия. Но я не вижу фактические файлы в файловой системе. Как записать числа в файловую систему?Запись в файловую систему не консоль
У меня есть это:
static void Main(string[] args)
{
string path = @"G:\Folder";
//string fileName = string.Format("{0}{1}-", part[0], part[part.Count - 1]);
var bans = BankAcoutNumbers.BANS;
const int MAX_FILES = 10;
const int BANS_PER_FILE = 10;
int bansCounter = 0;
var part = new List<int>();
//string fileName = string.Format("{0}-{1}", part[0], part[part.Count - 1]);
var maxNumberOfFiles = 10;
Stopwatch timer = new Stopwatch();
var fileCounter = 0;
if (!Directory.Exists(path))
{
DirectoryInfo di = Directory.CreateDirectory(path);
}
//var destiNationFile = new StreamWriter(string.Format(fileName, fileCounter + 1));
try
{
// foreach (var bank in BankAcoutNumbers.BANS.Take(100))
//{
while (fileCounter <= maxNumberOfFiles)
{
timer.Start();
foreach (var bank in BankAcoutNumbers.BANS)
{
part.Add(bank);
if(++bansCounter >= BANS_PER_FILE)
{
string fileName = string.Format("{0}-{1}", part[0], part[part.Count - 1]);
//var destinationFile = new StreamWriter(fileName);
//destiNationFile = new StreamWriter(fileName);
Console.WriteLine("NR{0}", fileName);
foreach (var partBan in part)
Console.WriteLine(partBan);
part.Clear();
bansCounter = 0;
if (++fileCounter >= MAX_FILES)
break;
//lineCounter = 0;
//destiNationFile.Flush();
//destiNationFile.Dispose();
//destiNationFile = new StreamWriter(string.Format(fileName, fileCounter + 1));
//fileCounter++;
}
//destiNationFile.WriteLine(bank);
//lineCounter++;
}
//fileCounter++;
//}
}
timer.Stop();
Console.WriteLine(timer.Elapsed.Seconds);
}
catch (Exception)
{
throw;
}
// Keep the console window open in debug mode.
System.Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
Спасибо
public class Program
{
//BankAcoutNumbers bankAccountNumbers = new BankAcoutNumbers();
static void Main(string[] args)
{
string path = @"G:\Folder";
//string fileName = string.Format("{0}{1}-", part[0], part[part.Count - 1]);
var bans = BankAcoutNumbers.BANS;
const int MAX_FILES = 10;
const int BANS_PER_FILE = 10;
int bansCounter = 0;
var part = new List<int>();
//part.Add(456456465);
//string fileName = string.Format("{0}-{1}", part[0], part[part.Count - 1]);
var maxNumberOfFiles = 10;
Stopwatch timer = new Stopwatch();
var fileCounter = 0;
if (!Directory.Exists(path))
{
DirectoryInfo di = Directory.CreateDirectory(path);
}
//var destiNationFile = new StreamWriter(string.Format(fileName, fileCounter + 1));
try
{
// foreach (var bank in BankAcoutNumbers.BANS.Take(100))
//{
while (fileCounter <= maxNumberOfFiles)
{
timer.Start();
foreach (var bank in BankAcoutNumbers.BANS)
{
part.Add(bank);
if(++bansCounter >= BANS_PER_FILE)
{
string fileName = string.Format("{0}-{1}", part[0], part[part.Count - 1]);
//var destinationFile = new StreamWriter(fileName);
//destiNationFile = new StreamWriter(fileName);
Console.WriteLine("NR{0}", fileName);
fileName = @"G:\\Folder" + fileName;
foreach (var partBan in part)
{
Console.WriteLine(partBan);
System.IO.File.WriteAllText(fileName, partBan.ToString());
}
part.Clear();
bansCounter = 0;
if (++fileCounter >= MAX_FILES)
break;
//lineCounter = 0;
//destiNationFile.Flush();
//destiNationFile.Dispose();
//destiNationFile = new StreamWriter(string.Format(fileName, fileCounter + 1));
//fileCounter++;
}
//destiNationFile.WriteLine(bank);
//lineCounter++;
}
//fileCounter++;
//}
}
timer.Stop();
Console.WriteLine(timer.Elapsed.Seconds);
}
catch (Exception)
{
throw;
}
// Keep the console window open in debug mode.
System.Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
Спасибо! Yura –