GetFullPath string fileName = "myfile.ext"; string path1 = @"mydir"; string path2 = @"\mydir"; string fullPath;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'
DirectoryInfo dir = new DirectoryInfo(@".\infosys"); FileInfo[] files = dir.GetFiles("*.xls"); //files[i].Name 文件名 //files[i].FullName 绝对地址
@"C:\Documents and Settings\aaron.zhang\My Documents\My Pictures\", "*.jpg");
参考
string fileName = "myfile.ext";
string path1 = @"mydir";
string path2 = @"\mydir";
string fullPath;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'
FileInfo[] files = dir.GetFiles("*.xls");
//files[i].Name 文件名
//files[i].FullName 绝对地址
如果不在同一目录下,设置ListBox的DisplayMember,ValueMember属性
有关文件的操作问题,本人已经上传了文件浏览器的代码, 你可以下载来做参考.