Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The FileSystem object offers a number of useful methods when parsing file paths.
The CombinePath method takes two paths and returns a properly formatted combined path.
The GetParentPath method returns the absolute path of the parent of the provided path.
The GetFileInfo method returns a FileInfo object that can be queried to determine the file's properties, such as its name and path.
Do not make decisions about the contents of the file based on the file name extension. For example, the file Form1.vb may not be a Visual Basic source file.
Use the DirectoryName and Name properties of the FileInfo object to determine a file's name and path. This example determines the name and path and displays them.
Dim testFile As System.IO.FileInfo
testFile = My.Computer.FileSystem.GetFileInfo("C:\TestFolder1\test1.txt")
Dim folderPath As String = testFile.DirectoryName
MsgBox(folderPath)
Dim fileName As String = testFile.Name
MsgBox(fileName)
Use the CombinePath
method, supplying the directory and name. This example takes the strings folderPath
and fileName
created in the previous example, combines them, and displays the result.
Dim fullPath As String
fullPath = My.Computer.FileSystem.CombinePath(folderPath, fileName)
MsgBox(fullPath)
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.
Documentation
How to: Get the Collection of Files in a Directory - Visual Basic
Learn more about: How to: Get the Collection of Files in a Directory in Visual Basic
How to: Find Files with a Specific Pattern - Visual Basic
Learn more about: How to: Find Files with a Specific Pattern in Visual Basic
How to: Create a File - Visual Basic
Learn more about: How to: Create a File in Visual Basic