Answers for "get folders in directory c#"

C#
2

get directory of file c#

using System.IO;

string file = "C:\Documents\file.txt";
Path.GetDirectoryName(file);
Posted by: Guest on December-03-2020
3

read folder c#

string mydocpath=Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);     
      StringBuilder sb = new StringBuilder();
      foreach (string txtName in Directory.GetFiles(@"D:\Links","*.txt"))
      {
        using (StreamReader sr = new StreamReader(txtName))
        {
          sb.AppendLine(txtName.ToString());
          sb.AppendLine("= = = = = =");
          sb.Append(sr.ReadToEnd());
          sb.AppendLine();
          sb.AppendLine();   
        }
      }
      using (StreamWriter outfile=new StreamWriter(mydocpath + @"\AllTxtFiles.txt"))
      {    
        outfile.Write(sb.ToString());
      }
Posted by: Guest on November-06-2020
1

get folders in directory c#

string[] folders = System.IO.Directory.GetDirectories(@"C:\My Sample Path\","*", System.IO.SearchOption.AllDirectories);
Posted by: Guest on October-30-2020

Code answers related to "get folders in directory c#"

C# Answers by Framework

Browse Popular Code Answers by Language