Group, I'm using the following code to read down to the third line of a text file. If it meets the criteria, I need to stop the read and then delete the file. However I'm finding it difficult to do this as everything I've tried has failed. Have you some thoughts on how I can do this? Do While objReader.Peek() <> -1 txtLine = objReader.ReadLine() programName = Trim(Microsoft.VisualBasic.Left(txtLine, 14)) If lineNo = 3 And programName = "(avl.allover)" Then fileSave = hotelFolder & "\Daily Reports\" & propertyNo & "Allover.txt" System.IO.File.Copy(fileName, fileSave, True) ' Stop the reading of the file and delete …

Member Avatar
Member Avatar
+0 forum 3

Hi group, I'm attempting to use a variable (i) to read the multiple files within a folder. However this doesn't seem to be working. Can you tell me what I'm doing wrong? For i = 0 To counter Dim objReader As New System.IO.StreamReader(getRestranName(i)) If System.IO.File.Exists(folderName) Then Do While objReader.Peek() <> -1 txtLine = objReader.ReadLine() If lineNo = 3 Then programName = Trim(Microsoft.VisualBasic.Left(txtLine, 10)) In advance, thanks for your help. Don

Member Avatar
Member Avatar
+0 forum 3

What I'm trying to do is take a source file and only pull specific lines out and display those lines to a label/textbox/etc. What's happening is I am able to pull the first line, however my loop is terminating and I do not receive the rest of the results. Here is what the source will look like: text1 = text1 text2 = text2 text3 = text3 text4 = text4 text5 = abcdefg (Yes) text6 = hijklmn (Yes) text7 = 1234567 (No) text8 = abcdefg (No) What I want to pull is any data that is marked Yes, so in this …

Member Avatar
Member Avatar
+0 forum 2

Hi, was wondering if it is possible to use openfiledialog to find a file and then use streamreader to read the text and use it in a variable? Got this so far but it comes up with this error: "Object reference not set to an instance of an object." the error appears on the "lblhighscore.Text = SR.ReadLine();" line OpenFileDialog HiScoreOpen = new OpenFileDialog(); HiScoreOpen.Filter = "TXT|*.txt"; if (HiScoreOpen.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string openFileLocation = HiScoreOpen.FileName; StreamReader SR = null; SR = new StreamReader(HiScoreOpen.FileName); lblhighscore.Text = SR.ReadLine(); SR.Close(); highscore = lblhighscore.text; Thanks

Member Avatar
Member Avatar
+0 forum 1

Hey all (who see this), I am currently writing a Login Script, and I am having trouble making StreamReader read a specific line in a text file. This is what I have so far (not the entire script, just the reader lines): [CODE] Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) Dim file As String = (path + "\LogDat.txt") Dim sr As New IO.StreamReader(file) Dim line1 As String = sr.ReadLine(1) '' Supposed to read line 1 Dim line4 As String = sr.ReadLine(4) '' Supposed to read line 4 Dim line9 As String = sr.ReadLine(9) '' Supposed to read line 9[/CODE] Any ideas …

Member Avatar
Member Avatar
+0 forum 2

Hi Am new to this and was wondering if anyone knew a solution to this problem. I am wanting to get information from a text file into different arrays. My current text file has a new line for each driver but I would like it to look something like this: Hamilton,Button,Alonso,Massa,Webber,Vettel Di Resta,Sutil,Rosberg,Perez,Buemi,Glock Each line of the text file represents a player and each player has 6 drivers. Each driver is seperated by a comma (,) which is what I need the program to understand. So for example I would want to import 'player one' drivers into the array: playerdrivers(1,1) …

Member Avatar
Member Avatar
+0 forum 2

Hello who knows how to create a search box in Visual Basic? I want the search box based on streamreader. In proper terms, when I will input a text, it has to read on a text file in drice C. I know the streamreader code but don't know the code to do a search.

Member Avatar
Member Avatar
+0 forum 41

I have an application that allows the user to open a file by clicking file -> open. The thing I'm trying to do is read the text file...but I don't know how to assign the user defined text file that the user opened to an object. I guess because I know what the user is going to open I can easily just do something like this: [CODE]Dim myFileIn as StreamReader myInFile = File.OpenText("warehouse1.txt")[/CODE] I want to be able to change "warehouse1.txt" to whatever text file the user opens. How can I do so? Thanks.

Member Avatar
+0 forum 0

The End.