Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

get folders in directory c#

string[] folders = System.IO.Directory.GetDirectories(@"C:My Sample Path","*", System.IO.SearchOption.AllDirectories);
Comment

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());
      }   
Comment

read folder c#


using System.IO;
...
foreach (string file in Directory.EnumerateFiles(folderPath, "*.xml"))
{
    string contents = File.ReadAllText(file);
}

Comment

PREVIOUS NEXT
Code Example
Csharp :: .net Core Get File Request 
Csharp :: how to use distinct in linq query in c# 
Csharp :: swaggergen add service not getting info in .net core 
Csharp :: asp net c# compare date to current 
Csharp :: selenium open chrome c# 
Csharp :: How to create connection string dynamically in C# 
Csharp :: c# console foreground color 
Csharp :: c# how to write an array in a single line 
Csharp :: c# compress string 
Csharp :: c# integer to bit string 
Csharp :: git find commits by message 
Csharp :: Cursor Lock and Visible in Unity 
Csharp :: razor confirm password validation 
Csharp :: unity camera follow player 3d smooth 
Csharp :: c# console save file 
Csharp :: access to element in object c# 
Csharp :: create line in unity 
Csharp :: unity key down 
Csharp :: c# array to string 
Csharp :: c# enum to int 
Csharp :: c# underscore variable 
Csharp :: assign color to value in c# 
Csharp :: add all elements in a list c# 
Csharp :: flip a character in unity 
Csharp :: hello world in unity c# 
Csharp :: No migrations configuration type was found in the assembly 
Csharp :: html beginform 
Csharp :: unity c# audio source 
Csharp :: c# remove first 5 characters from string 
Csharp :: create list in c# 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =