Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace zad1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- FolderBrowserDialog fbd = new FolderBrowserDialog();
- fbd.RootFolder = Environment.SpecialFolder.MyComputer;
- if (fbd.ShowDialog() == DialogResult.OK)
- {
- string katalog = fbd.SelectedPath;
- analizuj(new DirectoryInfo(katalog));
- }
- }
- void analizuj(DirectoryInfo di)
- {
- FileInfo[] fi = di.GetFiles("*.*");
- DirectoryInfo[] kat = di.GetDirectories();
- listBox1.Items.Add("Plik w katalogu " + di.FullName);
- FileInfo naj = null;
- foreach (FileInfo plik in fi)
- {
- if(naj == null && plik.Length > 1024 * 1024 * 10)
- {
- naj = plik;
- }
- else
- {
- if ((plik.CreationTime.Month >= 10) && (plik.CreationTime.Year >= 2016) && (plik.CreationTime.Day >= 1) && (plik.Length > 1024 * 1024))
- {
- naj = plik;
- }
- }
- }
- if(naj == null)
- listBox1.Items.Add("Nie ma takiego elementu");
- else
- listBox1.Items.Add(naj.ToString() + " czas utworzenia: " + naj.CreationTime + " ważący: " + naj.Length/1024/1024 + " Z katalogu: " + naj.DirectoryName);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement