I need to read data from a file in a C # console application.
What works:new StreamReader(@"..\\..\myData.csv");
Problem: it
..\\..\works because my exe file is in the bin / Debug directory. When I deploy my project, the path no longer works
Question: How can I link to myData.csv regardless of the location of the exe file?
I was hoping to find a method that returns the "root" of my console application. So far I have tried the following:
Process.GetCurrentProcess().MainModule.FileName
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location
Path.GetFullPath("bp.csv")
AppDomain.CurrentDomain.BaseDirectory
Directory.GetCurrentDirectory()
All these expressions lead me to the directory of the exe file, and not to the root.
I was just starting to read about isolated storage, but it would be nice to have something simpler. Any suggestions / recommendations?