hi guys, I am running windows application in vb.net.I have a xml file named mail.xml in folder named XmlFiles.In default.aspx.vb i have to get the path of mail.xml.What code i hve to write to make it possible?
From stackoverflow
-
You can use the GetFullPath static method of the Path class:
Dim fileName As string = "myfile.ext" Dim path1 As string = "mydir" Dim path2 As string = "\mydir" Dim fullPath As string fullPath = Path.GetFullPath(path1) Console.WriteLine("GetFullPath('{0}') returns '{1}'", _ path1, fullPath) fullPath = Path.GetFullPath(fileName) Console.WriteLine("GetFullPath('{0}') returns '{1}'", _ fileName, fullPath) fullPath = Path.GetFullPath(path2) Console.WriteLine("GetFullPath('{0}') returns '{1}'", _ path2, fullPath) ' Output is based on your current directory, except ' in the last case, where it is based on the root drive ' GetFullPath('mydir') returns 'C:\temp\Demo\mydir' ' GetFullPath('myfile.ext') returns 'C:\temp\Demo\myfile.ext' ' GetFullPath('\mydir') returns 'C:\mydir'
Example is from MSDN.
Another way is to use the fullName property of the FileInfo class (inherited from FileSystemInfo), see usage below:
Sub DisplayFileSystemInfoAttributes(ByVal fsi As FileInfo) ' Assume that this entry is a file. Dim entryType As String = "File" ' Determine if this entry is really a directory. If fsi.Attributes = FileAttributes.Directory Then entryType = "Directory" End If ' Show this entry's type, name, and creation date. Console.WriteLine("{0} entry {1} was created on {2:D}", _ entryType, **fsi.FullName**, fsi.CreationTime) End Sub
From MSDN as well.
0 comments:
Post a Comment