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

Hi folks, I've a problem when writing the contents of a file that was read using steam reader to the console window. It is only displaying part of the information that it should be showing. It should be displaying like this: http://i1370.photobucket.com/albums/ag266/Aaron_McCauley/1_zps4b8c3625.png But insted it displays like so (Notice the cursor jumps ahead about 5 lines): http://i1370.photobucket.com/albums/ag266/Aaron_McCauley/2_zps7f0e6259.png Anyone no of a fix? Heres the code of the method: //Searching by Town static void FindTown(CustomerStruct[] CustomerDeats) { string City; bool CityMatch = false; Console.Clear(); begin: try { Console.WriteLine("Please enter the customers Town "); City = Console.ReadLine(); } catch { Console.WriteLine("Failed. Please …

Member Avatar
Member Avatar
+0 forum 4

Forgive the begginer logic, but I can't afford a new degree until I get a raise. Goal: To create a dynamic text search based on a bulleted style procedure. Objective: Use a string reader to read a richtextbox line by line checking for the start and end of bullet points and outputting to prompt the end user to complete said step. Problem: Extracting the text between bullet points with grace. What I have so far: Dim objReader As New System.IO.StringReader(ProcedureDisplay.CurrentTest.Text) Dim TextLine As String 'Dim NextLine As String Dim BulletStartIndex As String Dim CurrentBullet As String BulletStartIndex = DocSearch.ProcedureFile.Text.IndexOf(ProcedureDisplay.CurrentTest.Text) - …

Member Avatar
Member Avatar
+0 forum 1

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

I want to send the verification mail before the user can sign in for which I have written some code, but the problem if that it gives the error "Could not find a part of the path", but I cannot understand why it is giving the error. The error occurs while trying to read the .txt fle using StreamReader. it says - Could not find a part of the path 'C:\JobPortal\EmailTemplates\VerifyNewUser.txt'. but it should be searching at the following path - [url]http://localhost:49292/JobPortal/EmailTemplates/VerifyNewUser.txt[/url] The code is pasted below: [CODE] protected void RegisterUser_CreatedUser(object sender, EventArgs e) { MembershipUser newUser = Membership.GetUser(RegisterUser.UserName); Guid …

Member Avatar
Member Avatar
+0 forum 2

I made a listview that display names using a streamreader. When I select a name and delete it the name that was below in the list will then take the information of the deleted name when it's displayed in the textboxes which shows name, address and email. How can I delete a name from the list so that it's gets completely deleted and dont leave behind any information? Im thinking it has something to to with the streamwriter and streamreader.

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

Hi all, i have a problem reading from a file in vb.net. I want to read from a file bit by bit so the file i write to is exactly the same, well almost because im planning on merging two files together but i can do that if i can figure out how to read and write exactly as the file was. I cant seem to get streamreader to work on non text files. Im probably just being retarded, but its been a long day so any help would be greatly appreciated. Many thanks crackruckles

Member Avatar
Member Avatar
-1 forum 3

Hi all, Ive been trying to find a seek method for StreamReader. I want to be able to reverse the file buffer by a couple characters at a time. How I have everything set up. [CODE] private void SortThread() { string[] lines; string line, totalLine = null; char[] fileInput = new char[1001]; TextReader tr; tr = new StreamReader("C:\\Users\\Anon\\Desktop\\test.txt"); line = null; do { try { //read 1k characters at a time tr.Read(fileInput, 0, 1000); //turn them to an array of lines line = new string(fileInput); lines = line.Split('\n'); //go backwards in the buffer and remove last line int reverse = …

Member Avatar
Member Avatar
+0 forum 8

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

magine there is search box (textbox), and below there are a search button with a rich text box. My text file located in the drive C is like this: Product: Cement Size: Big: Cost: 245 Type: Construction Product: Iron Size: Big Cost: 123 Type: Consruction Product: Glass Size: Small Cost: 23 Type: Non-Construction Product: Chocolate Size: Small Cost: 10 Type: Food I want to search only two types of items in my text file located in drive C, namely: Construction and Non-construction. When the user will type a product name, OR size, OR whatever, he must get results only for …

Member Avatar
Member Avatar
+0 forum 3

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.