program . And open with cmd like this :
MyProgramPath txtPath
But i see the index error .
Which one is correct for me ? args[0] or args[1] ?
if you open .txt through the "open as" function and select your application, it will give the full path to the file and then the expression will be true StreamReader sr = new StreamReader (args [0]); If you try to transfer the file name via cmd, it will not be able to open it for the reason that the application was invoked by means of cmd. Simply put args [0] will contain the name of the desired file, but when you try to open it the application will call the CurrentDirectory function to get the current directory of the application, but this directory will be C: \ Users \ Admin
args[0]
Обсуждают сегодня