How to read existing text files without defining path

后端 未结 8 1042
太阳男子
太阳男子 2020-12-14 05:53

Most of the examples shows how to read text file from exact location (f.e. \"C:\\Users\\Owner\\Documents\\test1.txt\"). But, how to read text files without writing full path

8条回答
  •  旧时难觅i
    2020-12-14 06:34

    If your application is a web service, Directory.CurrentDirectory doesn't work.

    Use System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "yourFileName.txt")) instead.

提交回复
热议问题