private string _filePath = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory);
上記の方法では、次のようなことがあります。
"C:\Users\myuser\Documents\Visual Studio 2015\Projects\myProjectNamespace\bin\Debug"
ここから、System.IO.Directoryを使用して後方にナビゲートできます。GetParent関数:
_filePath = Directory.GetParent(Directory.GetParent(_filePath).FullName).FullName;
さて、今あなたがC」のようなものを持っている:
_filePath = Directory.GetParent(_filePath).FullName;
1時間は2回あなたがmyProjectNamespaceを\になりますので、このようになり、あなたはビンを\になります:\ Users \ユーザーmyuserのプロジェクト\ myProjectNamespace」\ Visual Studioの2015 \ドキュメント、これだけ例えば、あなたのファイル名に、最終的なパスを添付\:
_filePath += @"\myfile.txt";
TextReader tr = new StreamReader(_filePath);
はそれがお役に立てば幸いです。
btw、StreamReaderの名前はちょっと混乱していますが、マイクロソフトは私の意見でこのTextStreamReaderの名前を付けたはずです –