Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //populating:
  2. var files = Directory.GetFiles(YOUR_FOLDER_PATH, "*.txt");
  3. foreach (var file in files)
  4. {
  5. var fileName = Path.GetFileName(file);
  6. //assuming ListBox:
  7. listBox.Items.Add(filename);
  8. }
  9.  
  10. //opening (from listbox)
  11. var fileName = Path.Combine(YOUR_FOLDER_PATH, listBox.SelectedItem.ToString());
  12. File.ReadAllText(fileName);
  13.  
  14. var fileNames = new List<string>();
  15. var fileContents = new Dictionary<string, string>();
  16. var filePaths = Directory.EnumerateFiles(folderBrowserDialog1.SelectedPath, "*.txt");
  17. foreach (var filePath in filePaths)
  18. {
  19. var fileName =new FileInfo(filePath).Name;
  20. fileNames.Add(fileName);
  21. fileContents.Add(fileName, File.ReadAllText(filePath));
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement