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
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("ftp://ftp.microsoft.com/disclaimer.txt") 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://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.
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).
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for