Advertisement
Guest User

getDirectories

a guest
Apr 7th, 2011
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.96 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.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. using System.Collections;
  10.  
  11. namespace Builder_Game_Update
  12. {
  13.     public partial class Step2 : Form
  14.     {
  15.         public Step2()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.         private string PathClient = Properties.Settings.Default.PathClient;
  20.         private string PathTo = Properties.Settings.Default.PathTo;
  21.         private Int64 AllFilesSize;
  22.         private Int64 DriveFreeSize;
  23.         int AllFilesCnt = 0;
  24.  
  25.         private bool CheckFreeSpace()
  26.         {
  27.             DirectoryInfo diPT = new DirectoryInfo(@PathTo);
  28.             DriveInfo di = new DriveInfo(diPT.Root.ToString());
  29.             DriveFreeSize = di.AvailableFreeSpace;
  30.  
  31.             if (DriveFreeSize < AllFilesSize)
  32.                 return false;
  33.             else
  34.                 return true;
  35.         }
  36.  
  37.         private void Step2_Load(object sender, EventArgs e)
  38.         {
  39.             DirectoryInfo diFromDir = new DirectoryInfo(@PathClient);
  40.  
  41.             DirectoryInfo[] diFromArr = diFromDir.GetDirectories();
  42.  
  43.             foreach (DirectoryInfo DirName in diFromArr)
  44.             {
  45.                 DirectoryInfo fFromDir = new DirectoryInfo(@PathClient + "/" + DirName);
  46.  
  47.                 foreach (FileInfo Fname in fFromDir.GetFiles())
  48.                 {
  49.                     FileInfo ufInfo = new FileInfo(@PathClient + "\\" + DirName + "\\" + Fname);
  50.                     AllFilesSize = AllFilesSize + ufInfo.Length;
  51.  
  52.                     LB_FULL.Items.Add(DirName + "\\" + Fname);
  53.                     AllFilesCnt++;
  54.                     Properties.Settings.Default.AllFilesCnt = AllFilesCnt;
  55.                 }
  56.             }
  57.             if (!CheckFreeSpace())
  58.             {
  59.                 MessageBox.Show("Nicht genügend Speicherplatz zum erstellen der Updates.");
  60.             }
  61.         }
  62.  
  63.         private void Step2_FormClosed(object sender, FormClosedEventArgs e)
  64.         {
  65.             Application.Exit();
  66.         }
  67.  
  68.         private void ToRight_Click(object sender, EventArgs e)
  69.         {
  70.             ArrayList sel = new ArrayList(LB_FULL.SelectedItems);
  71.             foreach (Object SelectedItem in sel)
  72.             {
  73.                 if (!LB_CRITICAL.Items.Contains(SelectedItem))
  74.                     LB_CRITICAL.Items.Add(SelectedItem);                                
  75.             }
  76.         }
  77.  
  78.         private void ToLeft_Click(object sender, EventArgs e)
  79.         {
  80.             ArrayList sel = new ArrayList(LB_CRITICAL.SelectedItems);
  81.             foreach (Object SelectedItem in sel)
  82.                 LB_CRITICAL.Items.Remove(SelectedItem);
  83.         }
  84.  
  85.         private void ToStep3_Click(object sender, EventArgs e)
  86.         {
  87.             this.GoToStep3();
  88.         }
  89.  
  90.         private void SaveParams_Click(object sender, EventArgs e)
  91.         {
  92.             ArrayList CL = new ArrayList(LB_CRITICAL.Items);
  93.             Properties.Settings.Default.CriticalList = CL;
  94.             Properties.Settings.Default.Save();
  95.         }
  96.  
  97.         private void TSMI_Exit_Click(object sender, EventArgs e)
  98.         {
  99.             Application.Exit();
  100.         }
  101.  
  102.         private void TSMI_Run_Click(object sender, EventArgs e)
  103.         {
  104.             this.GoToStep3();
  105.         }
  106.         private void GoToStep3()
  107.         {
  108.             ArrayList CL = new ArrayList(LB_CRITICAL.Items);
  109.             Properties.Settings.Default.CriticalList = CL;
  110.             Properties.Settings.Default.Save();
  111.  
  112.             if (CheckFreeSpace())
  113.             {
  114.                 Form Step3 = new Step3();
  115.                 Step3.Show();
  116.                 this.Hide();
  117.             }
  118.             else
  119.                 MessageBox.Show("Nicht genügend Speicherplatz zum erstellen der Updates.");        
  120.         }
  121.  
  122.         private void LB_FULL_SelectedIndexChanged(object sender, EventArgs e)
  123.         {
  124.  
  125.         }
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement