Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. /* list the files under the folder.*/
  2.  
  3. string filePath = @"C:\folder\data.txt";
  4. if (File.Exists(filePath) == true)
  5. {
  6. DirectoryInfo direcPath = new DirectoryInfo(@"C:\folder\");
  7. FileInfo[] rgFiles = direcPath.GetFiles();
  8.  
  9. foreach (FileInfo fi in rgFiles)
  10. {
  11. if(!(fi.Name == "data.txt"))
  12. {
  13. labelName.Add(fi.Name.Substring(0,(fi.Name.Length - 4)));
  14. }
  15.  
  16. }
  17. }
  18. else
  19. {
  20. Directory.CreateDirectory(@"C:\folder");
  21. FileStream fs = File.Create(@"C:\folder\data.txt");
  22. fs.Close();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement