Code for Reading and writing from a file in c#?



Code for Reading and writing from a file in c#?..

Answer / sabina

StreamWriter and StreamReader can be used to read and write
unicode chars to a file.

TextWriter adn TextReader are abstract base class from
which SW and SR inherits.

Stream is an abstract base class supports reading and
writing bytes into a file(arrays -> file) (file -> arrays)

FileStream exposes the stream ard the file

BinaryStream is used to write and read primitive
datatypes/encoded strings to files.

to encode string to bytes

byte[] b = new UTF8Encoding(true).GetBytes(string);

to decode string from bytes

String str = new UTF8Encodeing(true).GetString(b);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Code Interview Questions

Code for Searching for Multiple Matches with the MatchCollection Class?

0 Answers   TCS,


c# code to Count number of 1's in a given range of integer (0 to n)

0 Answers  


Code for Reading and writing from a file?

0 Answers   IBM, Xoriant,


program to check if a number is "perfect number".

1 Answers   Mind Tree, SoftSol,


program for addition of fraction(M/N + P/Q = Y/Z)

1 Answers   Mind Tree,






How to Create a Treeview Menu in ASP.NET with C#?

1 Answers  


how to change password in .net with c # with ado.net and also SQL server 2008 change password

1 Answers  


How to find No of classes,Packages,No of Methods per Classes and Depth of Inheritance for selecting source code in windows form application using c# .net? (Source code is input Program. It may be Java or .net) Please help me..) Thanks..)

0 Answers  


How to Link Different Data Sources Together?

0 Answers  


program for straight line(y=mx+c)

0 Answers   Mind Tree,


working with arrays

1 Answers  


how do i copy textbox contents of 1 form to another form

4 Answers   Wipro,


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)