Actually i want to know that what are the file read %26amp; write functions in C#, like fputs(),fgets(), or fprintf(), and fscanf(); and please also mention how to open file in c# . and how to close it.......
please reply............
What are the file read %26amp; write functions in C# ???
Ok, what you're describing is C functions which the concept is expanded in C#. Several objects are used to read and write files. They include the buffered streams, file streams, text read/writers to name a few. Most fall under the system.io class or input/output class of structure. An example is demonstrated below:
using System;
using System.IO;
class FSRead
{
public static void Main()
{
//Create a file stream from an existing file.
FileInfo fi=new FileInfo("c:\\csc.txt");
FileStream fs=fi.OpenRead();
//Read 100 bytes into an array from the specified file.
int nBytes=100;
byte[] ByteArray=new byte[nBytes];
int nBytesRead=fs.Read(ByteArray, 0, nBytes);
Console.WriteLine("{0} bytes have been read from the specified file.", nBytesRead.ToString());
}
}
I've also included some links below.
Hope this helps.
hollyhock
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment