Ejemplo n.º 1
0
    public ReadFile()
    {
        Cstring FilenameTemp = GetTempFileName();

        int nModifications = 0;

        // Read the file and display it line by line.
        System.IO.StreamReader file =
            new System.IO.StreamReader(Filename);
        System.IO.StreamWriter fileOut =
            new System.IO.StreamWriter(FilenameTempp);

        while ((line = file.ReadLine()) != null)
        {
            String strExpanded = Environment.ExpandEnvironmentVariables(line);
            if (!strExpanded.Equals(line))
            {
                ++nModifications;
            }
            file.WriteLine(strExpanded);
        }

        file.Close();
        fileOut.Close();
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            FileStream fs = new FileStream(@"C: \Users\HP\Downloads\far2.0\PT\lab2_min_prime_number\lab2_min_prime_number\lb2", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            FileStream ffs = new FileStream(@"C: \Users\HP\Downloads\far2.0\PT\lab2_min_prime_number\lab2_min_prime_number\lab2", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            StreamReader a = new StreamReader(fs);
            StreamReader b = new StreamReader(ffs);
            int cnt = 0;
            int min = 0;
            bool flag = false;
            string[] s = Console.ReadLine().Split();

            foreach (string h in s)
            {
                int number = int.Parse(h);
                cnt = 0;
                for (int i = 2; i <= number; i++)
                {


                    if (number % i == 0)
                    {
                        cnt++;
                    }
                    if (cnt >= 2)
                    {
                        break;

                    }
                }
                if (cnt == 1)
                {
                    if (!flag)
                    {
                        min = number;
                    }
                    if (min > number)

                        min = number;
                }
            }
            Console.WriteLine(min);
            b.WriteLine(min);
            a.Close();
            b.Close();
            fs.Close();
            ffs.Close();
            Console.ReadKey();
        }