1

I need to open a winforms FolderBrowserDialog from class library. We are calling the method via web socket from js and i need to open a FolderBrowserDialog in that method in order to get path and do some operations inside the folder. I tried both opening a new winform which contains a FolderBrowserDialog and FolderBrowserDialog without form but the form is freezing and doesnt response afer show or showdialog method. Is there a proper way to do it?

Information about the arcitechture: We have a .net web socket listener app and it is already running on the client machine. Frontend requets comes in to that app an it runs c# on the clients machine using reflection class and dlls on the client machine.

Cansın Memiş
  • 55
  • 2
  • 10
  • That's impossible. You can only do that in JavaScript and is sandboxed by the browser. https://stackoverflow.com/questions/21608763/how-open-a-folder-dialog-in-javascript – Lex Li Nov 11 '19 at 16:36
  • No actually we already achieved lots of things via web socket for example saving files opening files manupilating excel files via Microosft.office.interop. opening a dialog is the only thing that we can't achieve yet. Sorry but I don't accept your answer. Note that we are using the dlls on the clients computer via a web socket listener program and it is runnig on the clients machine – Cansın Memiş Nov 11 '19 at 16:53
  • 1) You didn't reveal the entire architecture of your application (which seems to span over a few components in different languages and installed in different locations), so it makes it impossible to really answer it. 2) Your examples are totally irrelevant. Showing a dialog (any UI) can be difficult/impossible if that piece of code runs in a locked down context. Saving/editing files, however, can be easy/allowed. – Lex Li Nov 11 '19 at 16:56
  • You are right i didn't explain the architehture well sorry for that – Cansın Memiş Nov 11 '19 at 16:58

1 Answers1

0

I stumbled upon this problem also and noticed that when in C# winforms FolderBrowserDialog doesn't work from a class that doesn't inherit from a Form.

I put the method which uses FolderBrowserDialog in a form which I knew will be open at the time, then saved handle to this form to a place accessible from my class (i.e. static class/DI injected service etc) and called my method through that proxy.

Mariusz
  • 908
  • 1
  • 13
  • 28