public static void Odwroc(string nazwa1, string nazwa2, int licznik)
{
if (nazwa1 == nazwa2)
{
Console.WriteLine("Nie można tak");
return;
}
if (!File.Exists(nazwa1))
{
Console.WriteLine("Nie istnieje plik o podanej nazwie");
return;
}
StreamReader sr = new StreamReader(nazwa1);
StreamWriter sw = new StreamWriter(nazwa2);
while (!sr.EndOfStream)
{
string text1 = sr.ReadLine();
string text2 = "";
for (int i = 0; i < text1.Length; i++)
{
if (text1[i] != ' ' || text1.Length - 1 != i)
{
text2 = text2 + text1[i];
}
else
{
char[] tab = text2.ToCharArray();
for (int j = 0; j >= licznik; j++)
{
tab[j] = text2[licznik - 1 - j];//w tym miejscu wyskakuje mi wyskok indeksu z tablicy(whyyyy?!!)
}
writefile.WriteLine(new string(tab) + " ");
sw.WriteLine();
text2 = "";
}
}
}
sw.Close();
sr.Close();
}