Kranthi Vardhan Kolluru

Kranthi Vardhan Kolluru

  • 1.2k
  • 512
  • 48.6k

Read a file from child project bin folder to parent project

Jul 27 2016 12:42 AM

i have two projects in one solution:

 : (Solution)Myapplication 
: project 1
ReadMsgtxt.cs
: project 2
bin
debug

Msg.txt

now i want to read "Msg.txt" file from "ReadMsgtxt.cs". Main parent project is "project1" but i want read file from parent project to child project. I don't want hardcode the path. please suggest using c# code to retrieve the file

Now i an using this code in ReadMsgtxt.cs but it is taking current file path i.e., project1 path
 
System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\Msg.txt") 

Answers (2)