G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 File_Browser
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         string drive;
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void getDriveInfoButton_Click(object sender, EventArgs e)
  24.         {
  25.             drivesListBox.Items.Clear();
  26.             drivesListBox.Items.Add("====Drives Info====");
  27.             DriveInfo[] drives = DriveInfo.GetDrives();
  28.             foreach(DriveInfo drive in drives)
  29.             {
  30.                 if (!drive.IsReady) continue;
  31.                 drivesListBox.Items.Add(drive.Name + "\t" + drive.TotalSize / 1024.0f / 1024 / 1024 + " GB");
  32.             }
  33.         }
  34.  
  35.         private void drivesListBox_SelectedIndexChanged(object sender, EventArgs e)
  36.         {
  37.             if (drivesListBox.SelectedItem == null) return;
  38.             string temp = drivesListBox.SelectedItem.ToString().Substring(0, 3);
  39.             if (!Environment.GetLogicalDrives().Contains(temp)) return;
  40.             drive = temp;
  41.             listFolders(new DirectoryInfo(drive));
  42.             pathLabel.Text = drive;
  43.         }
  44.  
  45.         private void listFolders(DirectoryInfo directory)
  46.         {
  47.             foldersListBox.Items.Clear();
  48.             DirectoryInfo[] folders = directory.GetDirectories();
  49.             foreach(DirectoryInfo folder in folders)
  50.             {
  51.                 if (folder.Attributes.HasFlag(FileAttributes.Hidden)) continue;
  52.                 foldersListBox.Items.Add(folder.Name);
  53.             }
  54.             FileInfo[] files = directory.GetFiles();
  55.             foreach(FileInfo file in files)
  56.             {
  57.                 if (file.Attributes.HasFlag(FileAttributes.Hidden)) continue;
  58.                 foldersListBox.Items.Add(file.Name);
  59.             }
  60.         }
  61.  
  62.         private void foldersListBox_DoubleClick(object sender, EventArgs e)
  63.         {
  64.             if (foldersListBox.SelectedItem == null) return;
  65.             string folder = foldersListBox.SelectedItem.ToString();
  66.             if (new DirectoryInfo(pathLabel.Text + folder).Attributes.HasFlag(FileAttributes.Directory))
  67.             {
  68.                 pathLabel.Text = pathLabel.Text + folder + @"\";
  69.                 listFolders(new DirectoryInfo(pathLabel.Text));
  70.             } else {
  71.                 string temp = pathLabel.Text + folder;
  72.                 if (temp.Contains(".txt"))
  73.                 {
  74.                     TextEditor textEditorForm = new TextEditor();
  75.                     textEditorForm.Show();
  76.                     textEditorForm.loadTextEditor(temp);
  77.                 } else
  78.                 {
  79.                     System.Diagnostics.Process.Start(temp);
  80.                 }
  81.             }
  82.         }
  83.  
  84.         private void backButton_Click(object sender, EventArgs e)
  85.         {
  86.             if(pathLabel.Text != drive && pathLabel.Text != "N/A"){
  87.                 string location = pathLabel.Text.Substring(0, pathLabel.Text.Length - 1);
  88.                 location = location.Substring(0, location.LastIndexOf(@"\") + 1);
  89.                 listFolders(new DirectoryInfo(location));
  90.                 pathLabel.Text = location;
  91.             }
  92.         }
  93.  
  94.         private void newFolderButton_Click(object sender, EventArgs e)
  95.         {
  96.             if (String.IsNullOrEmpty(drive) && pathLabel.Text == "N/A") return;
  97.             string name = Microsoft.VisualBasic.Interaction.InputBox("Enter Folder Name", "Creating New Folder", "New Folder");
  98.             if (String.IsNullOrEmpty(name)) return;
  99.             if (Directory.Exists(pathLabel.Text + name)) return;
  100.             try {
  101.                 Directory.CreateDirectory(pathLabel.Text + name);
  102.             } catch(Exception ex) {
  103.                 MessageBox.Show(ex.Message);
  104.             }
  105.             listFolders(new DirectoryInfo(pathLabel.Text));
  106.          }
  107.  
  108.         private void deleteButton_Click(object sender, EventArgs e)
  109.         {
  110.             if (foldersListBox.SelectedItem == null) return;
  111.             if (MessageBox.Show("Are you sure? You will delete: " + pathLabel.Text + foldersListBox.SelectedItem.ToString(), "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
  112.                 if(new DirectoryInfo(pathLabel.Text + foldersListBox.SelectedItem).Attributes.HasFlag(FileAttributes.Directory)){
  113.                     Directory.Delete(pathLabel.Text + foldersListBox.SelectedItem, true);
  114.                 } else{
  115.                     File.Delete(pathLabel.Text + foldersListBox.SelectedItem);
  116.                 }
  117.                 listFolders(new DirectoryInfo(pathLabel.Text));
  118.             }
  119.         }
  120.  
  121.         private void newTextFileButton_Click(object sender, EventArgs e)
  122.         {
  123.             if (String.IsNullOrEmpty(drive) && pathLabel.Text == "N/A") return;
  124.             string name = Microsoft.VisualBasic.Interaction.InputBox("Enter Text File Name", "Creating New Text File", "New Text File");
  125.             if (String.IsNullOrEmpty(name)) return;
  126.             string temp = pathLabel.Text + name;
  127.             if (!temp.Contains(".txt")) temp += ".txt";
  128.             if (File.Exists(temp)) return;
  129.             try
  130.             {
  131.                 File.CreateText(temp).Close();
  132.             }
  133.             catch (Exception ex)
  134.             {
  135.                 MessageBox.Show(ex.Message);
  136.             }
  137.             listFolders(new DirectoryInfo(pathLabel.Text));
  138.             TextEditor textEditorForm = new TextEditor();
  139.             textEditorForm.Show();
  140.             textEditorForm.loadTextEditor(temp);
  141.        }
  142.     }
  143. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top