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
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 |
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 |
Explain what a diffgram is, and a good use for one?
Explain repository pattern in asp.net mvc? : asp.net mvc
What is difference between session and cookies in asp net?
What?s the difference between Response.Write() andResponse.Output.Write()?
Explain the functionality of "EnableViewState" ? What happens if you want it on or off?
Usage of web.configuration ?
What are the main components of the ADO object model? How are they used?
2 Answers HCL, Syntax Softtech,
Is viewstate enabled by default?
Can we handle the error and redirect to some pages using web.config?
What are the difference between function and stored procedure in .net programming language?
You ve defined one page_load event in aspx page and same page_load event in code behind how will prog run?
Describe paging in asp.net?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)