Results 1 to 3 of 3

Thread: Open Txt files in folder One by one

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2013
    Posts
    29

    Open Txt files in folder One by one

    Hi guys,

    I want to open Txt files in a folder one by one. The sequence i need is:

    1. Scan folder for any file
    2. if file present, open first file
    3. read the file and update Mssql server table with record.
    4. Delete this file
    5. go to step 1.

    And the process loop goes on.

    Please any examples will be really helpful and much appreciated as i am beginner to VB.net.

    best regards,

    Bilal

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Open Txt files in folder One by one

    You can use the Directory.GetFiles method to get a list of file paths in a directory. It also allows you to filter based on the pattern of the file name, which would usually be by extension. You can then then use a For Each loop to go though that list of files. For each one, you can read the contents using the File class or, for more fine control, a StreamReader. ADO.NET can then be used to update your database. Finally, the File.Delete method will delete the file. You can find examples of any and all of those steps if you search the web. Don't expect an "example" of the entire process exactly as you want to do it because that's not an example. Examples show you how to do the bits and then you put the bits together to do what you want done.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2013
    Posts
    29

    Re: Open Txt files in folder One by one

    Thanks jmcilhinney,

    i know where you are coming from regarding examples, got the idea now and i can implement it .

    thanks

    best regards,

    Bilal

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width