Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

get directory of file c#

using System.IO;

string file = "C:Documentsfile.txt";
Path.GetDirectoryName(file);
Comment

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 :: how to loop an animation in unity 
Csharp :: csproj include folder and files 
Csharp :: c# tostring currency 
Csharp :: how to change color of a sprite in unity 
Csharp :: c# list of strings 
Csharp :: c# get last item in list 
Csharp :: unity 2d player move 
Csharp :: how to make an object appear and disappear in unity 
Csharp :: triangle minimum path sum 
Csharp :: c# get offset from timezone 
Csharp :: convert string to int and read it 
Csharp :: C# delete folder with all contents 
Csharp :: httpclient soap request c# 
Csharp :: C# How to read users input and display it 
Csharp :: c# check if string is all numbers 
Csharp :: make a list c# 
Csharp :: c# textbox numbers only 
Csharp :: c# find element by condition 
Csharp :: unity c# log an error or warning 
Csharp :: read embedded resource c# xml 
Csharp :: string isnullorempty vs isnullorwhitespace 
Csharp :: failed to read the request form. missing content-type boundary .net core 
Csharp :: string to biginteger c# 
Csharp :: read all lines from txt c# 
Csharp :: save byte array to file c# 
Csharp :: unity exception 
Csharp :: c sharp thread lambda 
Csharp :: how to make text show a variable in unity 
Csharp :: c# get all enum values 
Csharp :: c# turn negative number into positive 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =