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

How information about the user's locale can be accessed?

0 Answers   MindCracker,


Using shadow variable is good or bad for application?

1 Answers   Keane India Ltd,


What is the caspol.exe tool used for?

0 Answers  


How much is the pay-for-use service if I chose not to use microsoft-sponsored advertising?

0 Answers  


where can i gather the materials for MCP certification

2 Answers  


What are the different ways you would consider sending data across pages in ASP (i.e between 1.asp to 2.asp)?

1 Answers   Net Solution,


By default what is the Asp.Net application login context on IIS 5.0? By default the ASP.Net app runs in the context of a local user ASPNet on IIS version 5. On IIS version 6 on windows 2003 it is called Network service

0 Answers  


What is cookies cache and session?

0 Answers  


suppose i am Admin in my application and i have to terminate the session of the particular user in my application.........how can i do it....?????

1 Answers   L&T,


How does output caching work in ASP.NET?

0 Answers  


7. Do you have reference list?

4 Answers   CMC, Hotel Jobs, Mannar Company, Qatar Petroleums, Swatz Oils,


How could you modify xaml content from javascript?

0 Answers  


Categories