在我的C#程序中,我必须浏览目录.因此我使用该方法
System.IO.Directory.GetFiles(directory),当目录是像"C:\ Program File"这样的真实目录时,它运行良好,但当它是一个虚拟目录(例如:librairie目录)时,目录值如下所示:":: {031E4825-7B94- 4dc3-B131-E946B44C8DD5}\Pictures.library-ms"我不知道如何浏览它.
我正在使用FileSystemWatcher我的C#应用程序(在Windows上运行),以便在我的应用程序中更新我当前正在浏览的文件.当我浏览本地目录时,它工作得很好.重命名,删除或添加文件时会通知我.但是,例如,当我第一次在网络驱动器上重命名文件时,FileSystemWatcher通知我重命名操作,然后,当我重命名相同的文件或其他文件时,FileSystemWatcher通知我一个错误:
the specified server cannot perform the requested operation.
然后FileSystemWatcher没有通知我任何事情.
有时我可以在FileSystemWatcher没有通知我之前重命名两次......
这是我的测试代码:
static void Main(string[] args)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"N:\prive\defFolder";
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
watcher.Created += new FileSystemEventHandler(watcher_Changed);
watcher.Deleted += new FileSystemEventHandler(watcher_Changed);
watcher.Renamed += new RenamedEventHandler(watcher_Renamed);
watcher.Error += new ErrorEventHandler(watcher_Error);
watcher.EnableRaisingEvents = true;
Console.Read();
watcher.Dispose();
}
static void watcher_Error(object sender, ErrorEventArgs e)
{
Console.WriteLine("error : " + e.GetException().Message);
}
static void watcher_Renamed(object sender, …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我必须List<MenuItem>在WCF中向我的shell扩展发送一个.这些MenuItem由图标和标签组成.图标的类型是,System.Drawing.Icon但我必须工作System.Windows.Media.Imaging.BitmapImage.有没有办法转换BitmapImage成Icon?