Electron.IpcMain.Send and Arrays (in Electron.Net Api Demos) #314

Open
opened 2026-01-29 16:36:17 +00:00 by claunia · 0 comments
Owner

Originally created by @KinNeko-De on GitHub (May 20, 2019).

Hello,
i am new to Electron.Net and have a question. I am not very familar with javascript btw.

I used the Electron.Net Api Demos to open a file dialog that allows multiple selection.
I nearly copied everything from DialogsController.

string[] files = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); Electron.IpcMain.Send(mainWindow, "select-directory-reply", files);

files is an array.
I expected to get an array on the javascript side too.
But i only get a string. The related javascript code in the example expect only a single path.

The code in IpcMain goes over the array and creates multiple objects.
I think it was designed to do so. Right?

After i debugged the IpcMain code i decide to use :
'Electron.IpcMain.Send(mainWindow, "select-directory-reply", new object[] { files });'

Is that the simplest solution or do i miss something?
Should the example be edited to make it clearer how parameters should be passed?

Originally created by @KinNeko-De on GitHub (May 20, 2019). Hello, i am new to Electron.Net and have a question. I am not very familar with javascript btw. I used the _Electron.Net Api Demos_ to open a file dialog that allows multiple selection. I nearly copied everything from _DialogsController_. `string[] files = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); Electron.IpcMain.Send(mainWindow, "select-directory-reply", files);` _**files**_ is an array. I expected to get an array on the javascript side too. But i only get a string. The related javascript code in the example expect only a single path. The code in IpcMain goes over the array and creates multiple objects. I think it was designed to do so. Right? After i debugged the IpcMain code i decide to use : 'Electron.IpcMain.Send(mainWindow, "select-directory-reply", new object[] { files });' Is that the simplest solution or do i miss something? Should the example be edited to make it clearer how parameters should be passed?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#314