File Handling Concept in C#:-
The file is a collection of records, It is used to store information permanently under client machine.
C# provides IO namespace to perform the File Handling Task.
Operation on File:-
1) Write File:-
The file is a collection of records, It is used to store information permanently under client machine.
C# provides IO namespace to perform the File Handling Task.
Operation on File:-
1) Write File:-
class FileHandlingOperation
{
public static void Main()
{
File.WriteAllText("D://mydemo.txt", "Welcome in File Handling");
Console.ReadKey();
}
}
2) Read File
class FileHandlingOperation
{
public static void Main()
{
String s= File.ReadAllText("D://mydemo.txt");
Console.WriteLine(s);
Console.ReadKey();
}
}
3) Append File Operation:-
class FileHandlingOperation
{
public static void Main()
{
File.AppendAllText("D://mydemo.txt", "Welcome in File Handling");
Console.ReadKey();
}
}
Post a Comment
If you have any doubt in programming or join online classes then you can contact us by comment .