Command line cd option (change directory) in c #?

I want to write a simple C # console application to change the current command line directory to the directory in which the application is running. Looking through the MSDN System.IO.Directory.SetCurrentDirectory , it looks perfect for this, until I saw in the comments that:

'When the application terminates, the working directory is restored to its original location (the directory where the process was started).

And of course, when I tried this in a test application, it did not work. Does anyone know how to implement a CD option in C #?

+3
source share
2 answers

You can write a script wrapper package:

@ECHO OFF
FOR /F "tokens=*" %%i in ('someapp.exe') do SET TOOLOUTPUT=%%i 
CD %TOOLOUTPUT%

, , .

+3

, , cmd, .

+1

Source: https://habr.com/ru/post/1707895/


All Articles