use OpenFileDialog in "Dynamic code (.NET SDK" type universal function
Trying to create a OpenFileDialog like:
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = "c:\\";
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
...
...
does not work, and it renders SAP unresponsive.
Is it possible to let the user choose a file when executing a universal function? If yes, how?
1
-
I'm also running into this issue
-
I later found that you can use a new process to do this.
The code for universal function would be like follows. choose-file.exe would be a simple application that displays the choose file dialog and outputs the filename to console.
Directory.SetCurrentDirectory("D:\\Debug"); // this is where choose-file.exe is
var process = new Process{
StartInfo = new ProcessStartInfo{
FileName = "choose-file.exe",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
process.Start();
while (!process.StandardOutput.EndOfStream)
{
var line = process.StandardOutput.ReadLine();
application.StatusBar.SetText(line);
}
process.WaitForExit();
Iniciar sesión para dejar un comentario.
Comentarios
2 comentarios