Shocky Shocky - 2 months ago 21
C# Question

Place WinSCP.exe in project resources for WinSCP .NET assembly

I'm using

WinSCPnet.dll
in my project and to run correctly it needs
WinSCP.exe
in launch directory e.g.
project_path/obj/Debug
. But if I want to use my program, it needs to have this
.exe
file all the time in same folder otherwise the program will crash.

Is it possible to place
WinSCP.exe
into project resources so I don't have to place it in same directory everytime I move it?

(Sorry for my clunky English, don't downvote me for that :/ If you need some additional info I'll gladly post it)

Answer

The winscp.exe has to exist as a real file, at the moment you call the Session.Open.

So while you can store the winscp.exe to your application resources, you have to extract it somewhere (e.g. to a temporary folder), and set the Session.ExecutablePath accordingly, before you call the Session.Open.


Inspired by your question, I have added instructions for Embedding WinSCP executable as resource to the assembly documentation.