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
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.
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