Create a function to read a FileStream and return a string
Sample function on how to read a FileStream object and return a string.
public static string ReadFileStream(System.IO.FileStream fs) {//// declare a stringbuilder class to hold our dataStringBuilderStringBuilder sbWork = new StringBuilder();//// make sure our StringBuilder work variable is big enoughsbWork.EnsureCapacity((int)fs.Length); //sbWork.EnsureCapacity((int)fs.Length); // empty the work variablesbWork.LengthsbWork.Length = 0;intint nByte; // variable to hold the current byte.boolbool bReturnNull = true; // holds flag to determine if the function should return NULL//// read each byte in the file stream.whilewhile ((nByte = fs.ReadByte()) >= 0){ //{ // set the flag so we know to NOT return NULL.bReturnNullbReturnNull = false;//// convert the byte to a character.charchar cTemp = (char)nByte;//// append the character to our work variable.sbWork.Append(cTemp); } ifsbWork.Append(cTemp); } if (bReturnNull){ return{ return null;} else { return} else { return sbWork.ToString();}} }