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.Windows.Forms;
- namespace Filmsammler
- {
- public partial class Form1 : Form
- {
- private string path;
- private DirectoryInfo[] pathdirinfo;
- public Form1()
- {
- InitializeComponent();
- }
- private void m_btn_start_Click(object sender, EventArgs e)
- {
- DialogResult result = m_fb_dialog.ShowDialog();
- path = m_fb_dialog.SelectedPath;
- string[] paths = GetAllFolderNamesAsString(GetAllFolders(path));
- string filename = path + "output.txt";
- Clipboard.SetText(tofilestring(GetAllFolderNamesAsString(GetAllFolders(path)))+filelisttooutputstring(GetFileList(path,false)));
- }
- private void CollectFilms()
- {
- }
- public string filelisttooutputstring(List<string> files)
- {
- string outputstring = "";
- foreach (var file in files)
- {
- outputstring += file + "\n";
- }
- return outputstring;
- }
- public List<string> GetFileList(string Root, bool SubFolders)
- {
- List<string> FileArray = new List<string>();
- try
- {
- string[] Files = System.IO.Directory.GetFiles(Root);
- string[] Folders = System.IO.Directory.GetDirectories(Root);
- for (int i = 0; i < Files.Length; i++)
- {
- FileArray.Add(Files[i].ToString());
- }
- if (SubFolders == true)
- {
- for (int i = 0; i < Folders.Length; i++)
- {
- FileArray.AddRange(GetFileList(Folders[i], SubFolders));
- }
- }
- }
- catch (Exception Ex)
- {
- throw (Ex);
- }
- return FileArray;
- }
- public DirectoryInfo GetFolderInformation(string sFolder)
- {
- DirectoryInfo m_dir;
- m_dir = new DirectoryInfo(sFolder);
- return m_dir;
- }
- public DirectoryInfo[] GetAllFolders(string sFolder)
- {
- DirectoryInfo[] folders;
- folders = new DirectoryInfo(path).GetDirectories();
- return folders;
- }
- private string[] GetAllFolderNamesAsString(DirectoryInfo[] dirinfos)
- {
- string[] name = new string[999];
- string[] cleanname;
- int count = 0;
- foreach (var directoryInfo in dirinfos)
- {
- name[count] = directoryInfo.Name.ToString();
- count++;
- }
- cleanname = new string[count];
- for (int i = 0; i < count; i++)
- {
- cleanname[i] = name[i];
- }
- return cleanname;
- }
- private string tofilestring(string[] names)
- {
- string outputstring = "";
- foreach (string name in names)
- {
- outputstring += name + "\n";
- }
- return outputstring;
- }
- }
- }
Add Comment
Please, Sign In to add comment