Hi all,
I'm new bie to windows application..i want to search a key word inside a file..let say, if a file contains text "this is sample program...". If i search "sample" inside a file, it should give the exact matching.
------my code
FileStream fs = new FileStream("C:\ \a.txt", FileMode.Open, FileAccess.Read );
StreamReader fs1 = new StreamReader(fs );
String mystring="sampl e";
while (string == fs1. ____ )
{
Messagbox.show( "Yes i got ur string ..");
}
please help me to complete this missing keyword or code to get out of this problem.
------------------
thanks,
Mähésh Kumär. R 1 3496
use ReadLine() to read the file line for line and use string.IndexOf( ) to search your string within the returned string.
string line;
while ((line =ReadLine())!=n ull
{
if (line.IndexOf(" sample")!=-1)
{
//...
}
}
"Maheshkuma r.R" <cy**********@y ahoo.com> schrieb im Newsbeitrag news:ed******** ******@TK2MSFTN GP09.phx.gbl...
Hi all,
I'm new bie to windows application..i want to search a key word inside a file..let say, if a file contains text "this is sample program...". If i search "sample" inside a file, it should give the exact matching.
------my code
FileStream fs = new FileStream("C:\ \a.txt", FileMode.Open, FileAccess.Read );
StreamReader fs1 = new StreamReader(fs );
String mystring="sampl e";
while (string == fs1. ____ )
{
Messagbox.show( "Yes i got ur string ..");
}
please help me to complete this missing keyword or code to get out of this problem.
------------------
thanks,
Mähésh Kumär. R This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mehul Patel |
last post by:
Our .Net team have been pondering about using keyword.
We are using streams FileStream and BufferedStream. We use using
keyword at FileStream, and not BufferedStream which wraps FileStream.
So bunch of people said what if exception occurs buffered stream is
not closed.
My Argument is over advantages of using 'Using' keyword.
First Advantage being -- Using used for Dispose (Deterministic
|
by: Senthil |
last post by:
Hi,
The need is to read each line in a text file and based on the read
data decision has to be taken whether to reposition the file pointer. The
StreamReader.Position does not give current position. But it gives position
in multiples of 1024. Also, I am not finding a way to reposition the pointer
using FileStream-StreamReader combination. Due to this the condition
(FileLength = = File Position) misbehaves.
I did some investigation and...
|
by: Brian Henry |
last post by:
first question... I have a flat file which unfortinuatly has columns
seperated by nulls instead of spaces (a higher up company created it this
way for us) is there anyway to do a readline with this and not have it
affected by the null? because it is right now causes truncated data at wierd
places... but as soon as i manually with a hex editor change char(00) to
char(20) in the files it reads prerfectly... which leads me to my 2nd...
|
by: ABCL |
last post by:
Hi All,
I am working on the situation where 2 different
Process/Application(.net) tries to open file at the same time....Or one
process is updating the file and another process tries to access it,
it throws an exception.
How to solave this problem? So second process can wait until first
process completes its processing on the file.
Thanks in advance
|
by: Peter Duniho |
last post by:
I searched using Google, on the web and in the newsgroups, and found nothing
on this topic. Hopefully that means I just don't understand what I'm
supposed to be doing here. :)
The problem:
I am trying to use the SaveFileDialog class to get a filename, which is
subsequently opened for writing (write access, read sharing, but using
read/write sharing doesn't make the problem go away anyway). Sometimes, on
the statement where I...
| |
by: pbd22 |
last post by:
Hi.
I am somewhat new to this and would like some advice.
I want to search my xml file using "keyword" search and
return results based on "proximity matching" - in other words,
since the search string will often not produce a direct match,
the results will be based on proximity (50%, 20% 100%, etc).
are there any good examples out there on how to do keyword
searches on XML data? How should i set up my xml file so
|
by: djhexx |
last post by:
Hello. I have an ASP.NET application (C#) that I allow users to
upload files. Files get stored in a SQL2005 database. The file data
is stored in a varbinary(max) column.
When the user uploads the file, I store it in a database. When a user
requests to download a file, the file is retrieved from the database
and then sent to them.
The files go in there ok. This is how I store them:
|
by: JDeats |
last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting
and decrypting a file.
http://support.microsoft.com/kb/307010
In .NET 2.0 this approach is not fully supported (a .NET 2.0 build
with these methods, will appear to encrypt and decrypt, but the
resulting decrypted file will be corrupted. I tried encrypting a .bmp
file and then decrypting, the resulting decrypted file under .NET 2.0
is garbage, the .NET 1.1 build works...
|
by: alamodgal |
last post by:
hiiiiiii
I have a problem in highlighting searching keyword.Actually im using this function for searching
Public Function HighLight(ByVal Keyword As String, ByVal ContentFor As String)
Dim objHighLight As New highlight(Keyword, "<span class='searchKeyword'>{keyword}</span>")
ContentFor = objHighLight.process(ContentFor, False, False)
Return ContentFor
'Dim RegExp As Regex = New Regex(Keyword.Replace(" ", "|").Trim(),...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |