is there any code for opening a file without using any dialogbox? directly

Recommended Answers

All 4 Replies

Yes: StreamReader
System.IO.StreamReader

Example:

Imports System.IO
Module mod378486
   Sub ReadFile()
      Dim strData As String
      Dim fileIn As New StreamReader("c:\science\test.txt")
      While Not (fileIn.EndOfStream)
         strData = fileIn.ReadLine()
         Console.WriteLine(strData)
      End While
      fileIn.Close()
   End Sub
   Sub Main()
      ReadFile()
   End Sub
End Module

or

Console.WriteLine(IO.File.ReadAllText("c:\science\test.txt"))

tnx it helps a lot to my project :)

then please mark this thread as solved, thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.