.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Searching for a unused number in Text file

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF

Hello :)

I have a text file which looks like this :

Item 1
item 2
item 3
item 4
item 5
item 7
item 8
item 10 

(the text file exceeds 1000 lines, this is only a small part of it)

What I want to do is to find the first unused number( in this example it's 6) and let's say I want to print it in a text box.

The code I wrote for it, causes the program to freeze for maybe a half minute , so I hoped someone here could show me how they would solve this problem with
a less time consuming manner :)

Thanks on advance.

View Complete Post

More Related Resource Links

Writing to a text file



I have the following  subroutine in an asp.net application class. The subroutine writes data to a text file upon application login.   My question is that if this function was called at the same time by two different  users would it cause any kind of error. Is there a need for a try catch?

 Public Shared Sub writeToLogFile(ByVal UserName  As String)
        Dim strLogMessage As String = String.Empty
        Dim strLogFile As String = System.Web.HttpContext.Current.Server.MapPath("~/Log.txt") Dim swLog As StreamWriter
        strLogMessage = DateTime.Now.ToShortDateString().ToString()  " ==> " & UserName

        If Not File.Exists(strLogFile) Then
            swLog = New StreamWriter(strLogFile)
            swLog = File.AppendText(strLogFile)
        End If


The file reached the maximum download limit. Check that the full text of the document can be meaning



I'm facing an issue with the indexing.

I have 1 WFE+Index server+DB server.

Index server is not installed with MS FIlter pack 1.0

When crawling, the there will be document with warning in crawl log:
The file reached the maximum download limit. Check that the full text of the document can be meaningfully crawled.

Documents that with warning are such as doc, ppt, xls, docs, ppts and many others.
However, I view into the successful crawled document, there are doucments with ext doc and ppt.

For large file index, there are MaxGrowthFactor + MaxDownLoadSize required to be added into the index server.

As my understanding is, MS Filter Pack should installed into index server(already did, correct me if i'm wrong).

I looked into the Office SharePoint Seach(CA>Services in farm), if the server is appointed to "Use this server as indexing server", then MS Filter Pack is suppose to be installed into that particular server as well.

At the bottom, there also has another option is "Use all web front end for crawling".

The question here is, IF the option "Use all web front end for crawling" is selected.
Does the WED FRONT END Server required to installed the Ms Filte

Update Profile Database from text file using BDC



I have a requirement to import the profile properties from a text file in sFTP to update the MOSS Profile Database. The objective is to create a single repository for the Staff Directory in MOSS.

Can I use BDC to connect and update the Profile database?

What is the alternate approach?


Deleting Last Line of Text in a text file

Hi, I needed some help on the best way to delete the last line of  text in a text file. I have a subroutine that looks like this, but it is missing some code. Could anyone advise me on this? Dim strLogFile As String = System.Web.HttpContext.Current.Server.MapPath("~/Log.txt")         Dim fs As New FileStream(strLogFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None)         Dim swLog As New StreamReader(fs)         Dim array As String()         Dim value As String = swLog.ReadToEnd ''Array that holds the lines of the text file.         array = value.Split(vbCrLf)        ''code for deleting last line: . . .  fs.Close()

Searching plain-text files.

Hello, I was wondering if you guys could point me in the right direction toward implementing a page in my Web Form application that would be able to allow a user to search a text file which originally exists on a Window File share. Once the user searches for their text, I'd like the page to be split into two panes: One on the left that lists all the hits, each listing being a link which contains an excerpt of text around the link. And another pane on the right which shows the full text document with all the hits highlighted.Now, should I be loading the text file into a data base and be using something like Lucence .NET to search? Or is there a library of controls that can do all this for me already?By searching around the internet I've found bits and pieces of solutions to this problem, such as how to highlight result hits: http://www.knowdotnet.com/articles/highlightingsearchtext.htmlAnd how to perform database searches: http://www.asp.net/sql-server/videos/enabling-full-text-search-in-your-text-dataAm I going to have to painstakingly glue all these things together and write my own solution to this?Thanks for the help in advance.

Data loading from text file

Hi, I am loading the data from a flat file into a sql table. The values in one of the column have spaces at the end of the value. I want to remove those spaces and load into the table. I am thinking of using derived column and use rtrim on that column, how can I use that as an expression. Thanks.sqldev

Consistently running out of page file memory with full text indexer

Using MS SQL Server 2008 SP1 x64 Standard Edtion on Windows 2008 R2 Enterprise, I'm about to full-text index for the first time 1 table and 2 views. The table contains about 250'000 entries with a data space of 180 MB. As soon as I activate the full text indexing, the fdhost.exe task starts to consume slowly but surely all the available page file space (this can be easily watched using the Resource Monitor and the Commit Charge graph on the memory tab). Once all the virtual memory has been consumed, the server becomes unusable since it can't open any new windows any more, and RDP stops working. The machine specs are as follows: 12 GB of RAM 80 GB free on hard disk out of 136 GB 8 CPUs Custom size paging file with sizes between 24 GB - 60 GB (originally, this was system managed size, but then the server ran out of memory sooner) Max SQL server memory set to 6 GB (first 10 GB, then 8 GB) I've set the max fulltext crawl range to 8. During the indexing, the 8 CPUs are bit busy for a while, but not excessively. What is astonishing is that there is almost no use of physical memory during the indexing (I can see an increase from 2 GB to 3 GB which still leaves plenty of RAM available). Does anybody have an idea how I can convince fdhost.exe to consume physical memory and leave the paging memory alone? Or what else can I try?

Read a text file on another server from a web page

How do I read/write a text file on another server from a web page. I get the error "Access to the path '//Server2/mydatafiles/test.txt' is denied". I do not get the error if I am running the browser on the server where the files exist. I think I need to set permissions on the destination server in some way.   Can you help? Thanks  

convert xml file as text file using xml document

hi i want to convert to xml file to text file using xml document.. M not much aware of xml..so please guide me.... my boss told me don use xmltextreader and using xml document convert to txt file.....  

How to put text from an external text file into a text box on a report.

Hi all, We're moving from our legacy reporting app to SQL Server Reporting Services 2008 and I'm converting our reports slowly but surely.  In our organization, one of our departments sends out letters that have standard marketing messages and disclaimers that they put into .rtf files.  Currently, our reporting application has an RTF box control that can do that fairly easily.  I've not found a similar control in SSRS 2008.  My thought, then, was to use a piece of embedded code in the report to grab the necessary text from the file and reference it in the Value of a Placeholder (using a Code.<FunctionName>.ToString() statement) - using HTML tags for the necessary formatting for those files. I don't care if I have to convert the existing RTF files to HTML files to do this, that's not an issue.  The code I'd come up with is this:  Public Function GetTextFile(ByVal strFileName as String) As String Dim oFile as System.IO.File Dim oRead as System.IO.StreamReader oRead = oFile.OpenText(strFileName) GetTextFile = oRead.ReadToEnd() End Function And the Expression I was using to get the text from the file is:  =Code.GetTextFile("HTMLTest.txt").ToString() Where "HTMLTest.txt" is the file name that I'm using.  The text itself is just a line of text with some HTML tags included for formatting - bold, color,

How to tell repeater to wrap text after certain number of characters for a particular column ?

I have a column in my repeater which allows as many as 255 characters and causes the page contents pushed away to the right if any of the record has all 255 characters in that column. How can I tell it to wrap the text after 50 characters ?Thanks,

SSIS 2005 - Foreach loop container - Stopping the loop after processing X number of file?

I need to stop the Foreach loop container from processing more files in the folder than desired. Scenario:  If I only want 1 files processed, i need to stop the loop after it finds 1 file.  No matter what the contraints or tests or variables I set, the loop processes all the files in the folder.  This is bad because I need the value of the 1st mapped variable and not the last one it finds. I have tried counting records and setting variables used in the contraints but to no avail  Nothing seems to stop the loop. Please advise

Saving SSIS results to Log or text file using dtexec

Hi, How to save the SSIS package results to log file using dtexec command............please help regaridng this...........   Thanks in advance,

[regex] Extracting number preceding a particular text (in this case area unit).

Hi there, I'm looking for a regex to extract two numbers from the same text (they can be run independently, no need to extract them both in one go. I'm using yahoo pipes. Source Text: S$ 5,200 / month Negotiable, 1,475 sqft / 137 sqm (built-in) - Apartment, 10 Anson Road (D02) Need to extract as a number: 1,475 and also (but can be extracted on a separate instance) Need to extract as a number: 137 any guidance will be greatly appreciated. thanks in advance Paco

Retrieving a number from a comboBox value including number and text

Hi, I am using C# and trying to retrieve a number from a value in a comboBox that contains both numbers and text.  I am modifying what is in the comboBox using the following format which is working fine ("130mm Corus-Comflor 46" is a value already loaded into the comboBox):   this .floorComboBox.Text = "130mm Corus-Comflor 46" ;   This line of code is changing what is in the comboBox and from what is written in the combo box, I would like to be able to retrieve just the first number '130' from the newly updated comboBox so that I can use it elsewhere.  I am not sure how to go about this and I have looked online for something similar, but with no luck. Best regards, Mike  

Saving a generated text file

 I have an application that collects data and puts it in a text file.  When the data collection is complete the UI offers the user the opportunity to save or open the text file with a dialog box using this code: Response.Clear(); Response.ClearHeaders(); Response.AppendHeader("Content-Disposition", "attachment; filename=" + outputFilename + ";"); Response.Cache.SetCacheability(HttpCacheability.Private); Response.ContentType = "text/plain"; Response.WriteFile(outputFilePath + outputFilename); Response.End(); Response.Flush(); The problem is this.  The starting interface allows the user to select a large number of data gathering points.  If all are selected the program will run for about 90 minutes.  Sometimes it will present the dialog box, sometimes not.  Sometimes it will present the dialog box, but regardless of whether the user selects save or open, the dialog box simply disappears, and the data text file is neither displayed nor saved to the client system. When fewer data gather points are selected, and the program runs for 15 minutes or less, there is no problem.  The resulting data can be saved or displayed. The actual data text file is initially stored in the temporary path directory on the web server.  On at least one occasion, where the dialog box disappeared, I was able to

How to redirect bad date(xxx,9999) in datereceived column in text file in ssis

I want to redirect bad date format from flate file source to log table. I tried with redirect row but it is not working. Thanks in advance
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend