How to access remote files from VB.NET

Written by stephen byron cooper Google
  • Share
  • Tweet
  • Share
  • Pin
  • Email
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.

Skill level:
Moderately Easy

Other People Are Reading

Things you need

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

Show MoreHide

Instructions

  1. 1

    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.

  2. 2

    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.

  3. 3

    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("ftp://ftp.microsoft.com/disclaimer.txt") This code reads the file and displays it in a text box called Text1.

  4. 4

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

  5. 5

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

Don't Miss

Resources

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

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