Hi Raul,
i've had the same Issue with Windows 8.1 and Windows 10 - (SAP stays in the foreground):
My Problem is solved by creating of a new empty Windows-Form witch is owner of the Folder- or FileBrowser-Dialog.
public static string GetFolderPath()
{
string path = "";
try
{
Thread t = new Thread((ThreadStart)delegate
{
FolderBrowserDialog objDialog = new FolderBrowserDialog();
//FileDialog objDialog = new OpenFileDialog();
objDialog.Description = "Please select a Folder";
objDialog.SelectedPath = @"C:\"; // or any other path you want to start...
objDialog.ShowNewFolderButton = true;
//create a Form for ownership (SAP-Window won't work)
Form g = new Form();
g.Width = 200;
g.Height = 200;
g.Activate();
g.BringToFront();
g.Visible = true;
g.TopMost = true;
g.Focus();
DialogResult objResult = objDialog.ShowDialog(g);
Thread.Sleep(100);
if (objResult == DialogResult.OK)
{
path = objDialog.SelectedPath;
}
}
)
{
IsBackground = false,
Priority = ThreadPriority.Highest
};
t.SetApartmentState(ApartmentState.STA);
t.Start();
while (!t.IsAlive) ;
Thread.Sleep(1);
t.Join();
}
catch (Exception ex)
{
//Exception handling...
//Funktionen.WriteError(ex);
}
return path;
}