protected void Page_Load(object sender, EventArgs e) { DirectoryInfo dif = new DirectoryInfo(@"D:\Shared\work software"); if (!dif.Exists) return; ListItem(dif); } private void ListItem(FileSystemInfo info) { if (info == null) return; DirectoryInfo dir = info as DirectoryInfo; FileSystemInfo[] files = dir.GetFileSystemInfos(); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i] as FileInfo; if (file != null) { list.Items.Add(file.FullName); } else { ListItem(files[i]); } } }
Process p = new Process(); ProcessStartInfo pi = new ProcessStartInfo; pi.FileName = "C:\"; pi.Verb = "Open"; pi.CreateNoWindow = false; p.StartInfo = pi; p.Start();
protected void Page_Load(object sender, EventArgs e)
{
DirectoryInfo dif = new DirectoryInfo(@"D:\Shared\work software"); if (!dif.Exists) return; ListItem(dif); } private void ListItem(FileSystemInfo info)
{
if (info == null) return; DirectoryInfo dir = info as DirectoryInfo;
FileSystemInfo[] files = dir.GetFileSystemInfos(); for (int i = 0; i < files.Length; i++)
{
FileInfo file = files[i] as FileInfo; if (file != null)
{
list.Items.Add(file.FullName);
}
else
{
ListItem(files[i]);
}
}
}
Process p = new Process(); ProcessStartInfo pi = new ProcessStartInfo; pi.FileName = "C:\";
pi.Verb = "Open";
pi.CreateNoWindow = false; p.StartInfo = pi;
p.Start();
void Open(string path)
{
System.Diagnostics.Process.Start(path);
}
比如:输入一个文件夹地址 c:\a\ , 点 打开 按钮 就直接 打开了 c:\a\ 这个文件夹。
{
string path = "D:\\kn\\名侦探柯南";
System.Diagnostics.Process.Start(path);
}
虽然能够实现,但是我不理解原理.哪位能细讲一下?