How to access remote files from VB.NET

Written by stephen byron cooper | 13/05/2017
How to access remote files from VB.NET
Create VB.NET projects in Visual Studio. (Microsoft Corporation)

Visual Basic .NET, also known as VB.NET, is a programming language produced by Microsoft. It enables the development of Windows-style applications. The language includes the capabilities to read and write to the files. As file access is organized by the operating system on behalf of VB.NET, it can access any file that is not hidden or password protected, even if that file is on another computer.

Ensure that your computer is connected to a network, or to the internet. Check that you can communicate with the computer holding the file you want to get the file from. If the remote computer is accessible over a network, open a Windows Explorer and click on the folders icon at the top of the window. Look down the file directory structure in the left panel to find “My Network Places." Click on this icon and find the computer listed in the right panel of the explorer. For a file reached over the internet, first check the address of the file by entering it into your web browser’s address bar.

Note down the name of the computer you need to access. Double click on that computer to access its directory structure. Note down the path to the file you want to open and also the full file name, including the extension.

Open Visual Studio and open the program you want to include the remote file access in. Microsoft Developers Network recommends the following code for reading the contents of a file across the internet: Text1.Text = Inet1. _ OpenURL("") This code reads the file and displays it in a text box called Text1.

Create a function to copy a file from a remote computer over the internet. Add code in the format: Inet1.Execute "FTP://", _ "GET disclaimer.txt C:\Temp\Disclaimer.txt" This is Microsoft Developers Network’s example of code that would access the ftp server of, get the file called “disclaimer.txt” and save it at “C:\Temp\Disclaimer.txt” on the local computer.

Access a file over a network in VB.NET by using the File class. This class contains a number of file manipulation methods, including Open, Close, Copy, Create and Delete. The class can handle files both on the local computer and on a computer across the network. Use the network address for the path to the file. The class returns a value as a FileStream type, which must be declared. An example of File operations is: Dim MyFile As FileStream = File.Open("\server\folder\subfolder\file.txt", FileMode.Open) The Microsoft Developers Network site has more information on the other methods available in the File class (see Resources).

Things you need

  • PC connected to the internet or a network
  • Visual Studio

Show MoreHide


  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.