你好,
如果我没有理解错的话,应该是你需要使用这个属性:
Gets the uniform resource identifier (URI) for the location from which a XAML browser application (XBAP) application was launched.
通过它得到的路径类似这样:
经过简单处理,可以转换为当前目录路径,然后用递归函数遍历文件夹和文件,以下为我的示例:
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(BrowserInteropHelper.Source.ToString());
DirSearch(BrowserInteropHelper.Source.ToString().Replace("file:///","")+"/../");
}
static void DirSearch(string dir)
{
try
{
foreach (string f in Directory.GetFiles(dir))
Debug.WriteLine(f);
foreach (string d in Directory.GetDirectories(dir))
{
Debug.WriteLine(d);
DirSearch(d);
}
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
Debug输出:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.