How can we read a columnised text data in ASP.Net C#?
Columnised means my data is stored in a text file and I
have numeric data or string data in this file. For ex. If I
am searching for the data of gender and I know that gender
data is stored at column 32 in text file. How can I get
this data in ASP.Net page. Thanks for help in advance.

Answers were Sorted based on User's Feedback



How can we read a columnised text data in ASP.Net C#? Columnised means my data is stored in a text..

Answer / sandeep kumar shaw

we need that text file convert into integer for example
cint(Textbox1.text)..

Is This Answer Correct ?    6 Yes 6 No

How can we read a columnised text data in ASP.Net C#? Columnised means my data is stored in a text..

Answer / praveen kumar

string OpenPath, contents;
int tabSize = 4;
string[] arInfo;
string line;
DataTable table = CreateTable();
DataRow row;
try
{

OpenPath = Server.MapPath(".") + @"\My
File.log";
string FILENAME = OpenPath;
//Get a StreamReader class that can be used
to read the file
StreamReader objStreamReader;
objStreamReader = File.OpenText(FILENAME);
while ((line = objStreamReader.ReadLine())
!= null)
{
contents =
line.Replace(("").PadRight(tabSize, ' '), "\t");


// define which character is seperating
fields
char[] textdelimiter = { ']' };

arInfo = contents.Split(textdelimiter);
for (int i = 0; i <= arInfo.Length; i++)
{
row = table.NewRow();
if (i < arInfo.Length)
row["Type"] =
arInfo[i].ToString().Replace("[", " ");

if (i + 1 < arInfo.Length)
row["Source"] = arInfo[i +
1].ToString().Replace("[", " ");
if (i + 2 < arInfo.Length)
row["Time"] = arInfo[i +
2].ToString().Substring(1);
if (i + 3 < arInfo.Length)
{
row["Description"] = arInfo[i +
3].ToString().Replace("[", " ");
table.Rows.Add(row);
}
i = i + 2;
}
}

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More ASP.NET Interview Questions

Explain the difference between codebehind="mycode.aspx.cs" and src="mycode.aspx.cs"?

0 Answers  


33) You create English, French, and German versions of your ASP.NET application. You have separate resource files for each language version. You need to deploy the appropriate resource file based on the language settings of the server. What should you do? A . Create an installer and set the Installer.Context property for each version of your application. B . Create an installer that has a launch condition to verify the locale settings. C . Create an installer that has a custom action to install only location-specific files. D . Create an installer that has an MsiConfigureProduct function to install the appropriate version.

2 Answers   Friedkin, ISH, Syntax, Syntax Softtech,


What is gridview in asp.net?

0 Answers  


What are Sticky Sessions?

2 Answers   Infosys,


Whats the difference between registerclientscriptblock, registerclientscriptinclude and registerclientscriptresource?

0 Answers  






Describe and In Process Vs Out of Process component. Which is faster?

2 Answers   Syntax Softtech,


What is caching? What are the different types of caching?

6 Answers  


what is the differance between native code & managed code?

5 Answers   Microsoft,


What are Master Pages in ASP.NET?

0 Answers  


WHAT ARE DEFFERENCE BETWEEN DATALIST AND DATAGRID

1 Answers   Seion Infotech,


What is bound controls

0 Answers   MCN Solutions,


with which controls you worked in Asp.net 2.0?

2 Answers   HP, nTech Solutions,


Categories