Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4.  
  5. class MainClass
  6. {
  7.     public static void Main()
  8.     {
  9.         FileStream fin;
  10.         String s;
  11.         String lofasz;
  12.         List<String> utvonalak = new List<String>();
  13.  
  14.         try
  15.         {
  16.             fin = new FileStream("C:\\malamala.txt", FileMode.Open);
  17.         }
  18.         catch (FileNotFoundException exc)
  19.         {
  20.             Console.WriteLine(exc.Message + "Cannot open file.");
  21.             return;
  22.         }
  23.  
  24.         StreamReader fstr_in = new StreamReader(fin);
  25.  
  26.         // Read the file line-by-line.
  27.         while ((lofasz = fstr_in.ReadLine()) != null  &&  (s = fstr_in.ReadLine()) != null)
  28.         {
  29.             utvonalak.Add(s);
  30.         }
  31.  
  32.         fstr_in.Close();
  33.  
  34.         Random random = new Random();
  35.         long tarhely=959447040;
  36.         String targetpath=@"D:\Lejatszora";
  37.         String aktual, filenev, targetfile;
  38.         FileInfo meret;
  39.         while (tarhely>0)
  40.         {
  41.         aktual = utvonalak[random.Next(1, utvonalak.Count)];
  42.         filenev=Path.GetFileName(aktual);
  43.         targetfile=Path.Combine(targetpath,filenev);
  44.             File.Copy(aktual,targetfile);
  45.             meret = new FileInfo(aktual);
  46.             tarhely=tarhely - meret.Length;
  47.         }
  48.        
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement