Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# create a text file

//File and path you want to create and write to
string fileName = @"C:TempTemp.txt"; 
//Check if the file exists
if (!File.Exists(fileName)) 
{
    // Create the file and use streamWriter to write text to it.
	//If the file existence is not check, this will overwrite said file.
	//Use the using block so the file can close and vairable disposed correctly
    using (StreamWriter writer = File.CreateText(fileName)) 
    {
        writer.WriteLine("Hello World");
    }	
}
Comment

write text files with C#

// Create a file to write to.
string createText = "Hello and Welcome" + Environment.NewLine;
File.WriteAllText(path, createText);

...

// Open the file to read from.
string readText = File.ReadAllText(path);
Comment

PREVIOUS NEXT
Code Example
Csharp :: convert to base64 c# 
Csharp :: center an image horizontally and vertically 
Csharp :: unity right click on gameobject 
Csharp :: draw sphere gizmo unity 
Csharp :: how to set serial number in gridview in asp net 
Csharp :: disappear after time unity 
Csharp :: unity how to convert to byte 
Csharp :: how to make a resizable window in monogame 
Csharp :: c# new thread 
Csharp :: fade text unity 
Csharp :: unity get distance between two objects 
Csharp :: kotlin random number 
Csharp :: how to set the fps in monogame 
Csharp :: for loop unity 
Csharp :: get application path c# 
Csharp :: unity create cube in script 
Csharp :: unity change text color 
Csharp :: unity get speed of object 
Csharp :: c# if debug 
Csharp :: c# unzip files 
Csharp :: c# difference between break and continue 
Csharp :: check if gameobject exists unity 
Csharp :: how to lock and hide the cursor unity 
Csharp :: Unity rotate player to mouse point slowly 
Csharp :: c# debug console log 
Csharp :: c# round to 2 decimal places 
Csharp :: unity know when mouse on ui 
Csharp :: Join Or Create Room() photon 
Csharp :: unity particle system playing at the wrong location 
Csharp :: wpf image clip with rounded corners 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =