Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace zad1
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void button1_Click(object sender, EventArgs e)
  22. {
  23. FolderBrowserDialog fbd = new FolderBrowserDialog();
  24. fbd.RootFolder = Environment.SpecialFolder.MyComputer;
  25. if (fbd.ShowDialog() == DialogResult.OK)
  26. {
  27. string katalog = fbd.SelectedPath;
  28. analizuj(new DirectoryInfo(katalog));
  29. }
  30. }
  31. void analizuj(DirectoryInfo di)
  32. {
  33. FileInfo[] fi = di.GetFiles("*.*");
  34. DirectoryInfo[] kat = di.GetDirectories();
  35. listBox1.Items.Add("Plik w katalogu " + di.FullName);
  36. FileInfo naj = null;
  37.  
  38. foreach (FileInfo plik in fi)
  39. {
  40. if(naj == null && plik.Length > 1024 * 1024 * 10)
  41. {
  42. naj = plik;
  43. }
  44. else
  45. {
  46. if ((plik.CreationTime.Month >= 10) && (plik.CreationTime.Year >= 2016) && (plik.CreationTime.Day >= 1) && (plik.Length > 1024 * 1024))
  47. {
  48. naj = plik;
  49. }
  50. }
  51.  
  52. }
  53.  
  54. if(naj == null)
  55. listBox1.Items.Add("Nie ma takiego elementu");
  56. else
  57. listBox1.Items.Add(naj.ToString() + " czas utworzenia: " + naj.CreationTime + " ważący: " + naj.Length/1024/1024 + " Z katalogu: " + naj.DirectoryName);
  58.  
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement