Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Should user input data validation occur server-side or client-side? Why?

3 Answers   NIC, Siebel Systems,


Which method do you invoke on the DataAdapter control to load your generated dataset with data?

2 Answers  


What is the difference between custom controls and user controls?

0 Answers  


what is state management,what is the purpose of it,how it will be implemented in real time?

2 Answers  


different architectures of asp.net?

1 Answers  


Is global asax mandatory?

0 Answers  


how to get modified rows from Dataset

1 Answers   CGI,


What is Cookies Less Session?

0 Answers  


what are configuration files?

0 Answers  


What is CTE in sql server 2005?

3 Answers   Minecode,


Tell something about state management in asp.net?

3 Answers   Accenture,


Difference between singleton and singlecall.

0 Answers  


Categories