I'm working on fixing a feature in a c#.net app where the user can right click on a file name and they'll have an "Open in Explorer" option. When they click it a new explorer window opens up with that file selected.
The problem is that if the feature is used to open an audio file, then it seems to infrequently work. The first few attempts will appear selected in an explorer window with no issue.
However, every once in a while the explorer window will hang for half a second or so as it opens, and no file will be selected when it resumes. If you then go back to the app and try it again on that same file, then explorer will open with the file selected; no issue.
So far, it appears to work without fail for text based files and directories. Only audio files have this issue.
I've tried most of the stuff already on stackoverflow concerning the "/select" CL arg, but none of it has solved the issue. Any ideas?
The current code attempt:
void MyFunc(object sender, EventArgs e)
{
string filePath= "";
// Code that gets full filepath is here - it has so far always returned a correct path
if (!string.IsNullOrEmpty(filePath))
{
filePath = filePath.Replace(@"/", @"\");
if (File.Exists(filePath))
{
string args = string.Format("/select,\"{0}\"", filePath);
Process.Start("explorer.exe", args);
}
}
}
Extra information:
thanks
After talking with more people, we found out it was a quirk with viewing music files in Explorer.exe. I ended up using this as a mitigation, emailing the couple of users, and including instructions on the help doc.