public string GetFile(string objXml)
{
XmlDocument xmlINPUT = new XmlDocument();
xmlINPUT.LoadXml(objXml);
string directoryName =
xmlINPUT.GetElementsByTagName("DIRECTORY")[0].Value.ToString();
string fileName =
xmlINPUT.GetElementsByTagName("FILE")[0].Value.ToString();
XmlDocument xmlOUTPUT = new XmlDocument();
XmlElement xmlROOT = xmlOUTPUT.CreateElement("ROOT");
xmlOUTPUT.AppendChild(xmlROOT);
XmlElement xmlFILE = xmlOUTPUT.CreateElement("FILE");
xmlFILE.SetAttribute("NAME",fileName);
/* Conversion of file into byte stream STARTS */
Byte[] byteFILE;
FileStream fs = new
FileStream("\\"+directoryName+"\\"+fileName,System .IO.FileMode.Open,System.IO.FileAccess.Read);
byteFILE = new byte[fs.Length];
BufferedStream bs = new
BufferedStream(fs,Convert.ToInt32(fs.Length));
char[] charFILE = new char[byteFILE.Length];
for(int i = 0; i < fs.Length; i++)
{
byteFILE[i] = (byte)bs.ReadByte();
charFILE[i] = Convert.ToChar(byteFILE[i]);
}
string stringFILE = charFILE.ToString();
/* Conversion of file into byte stream ENDS */
xmlFILE.AppendChild(xmlOUTPUT.CreateCDataSection(s tringFILE));
xmlROOT.AppendChild(xmlFILE);
return xmlOUTPUT.InnerXml.ToString();
}