コンピュータのデスクトップに保存されている xxx.txt ファイルを開きたいのですが、プログラムで
errorパーサー エラー エスケープ シーケンス '\D' を認識できません。私はのパスを与えようとしています
"C:\Documents and Settings\user\Desktop\xxx.txt"としてファイルします。
私は正しい方法でパスを与えていますか、それともそれを与える他の方法はありますか
コンピュータのデスクトップに保存されている xxx.txt ファイルを開きたいのですが、プログラムで
errorパーサー エラー エスケープ シーケンス '\D' を認識できません。私はのパスを与えようとしています
"C:\Documents and Settings\user\Desktop\xxx.txt"としてファイルします。
私は正しい方法でパスを与えていますか、それともそれを与える他の方法はありますか
\
C#文字列のエスケープ文字です。改行(\n
)などの特殊文字に使用されます。リテラルを書くには、\
別のリテラルで引用する必要があります\
:
string myFileName = "C:\\Documents and Settings\\user\\Desktop\\xxx.txt";
別の方法は、文字を含む文字列の引用符を無効にすること@
です。
string myFileName = @"C:\Documents and Settings\user\Desktop\xxx.txt";
次のパスを使用します。
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "xxx.txt");
I had to access a file in my project, so the folder 'lib' which contains all the files i need, i placed this folder in the 'bin' folder of my project, and now i can access any file i need from lib folder. In code path i used is as follows:
StreamReader sr = new StreamReader("..\\lib\\myFile.src");
Works well! :)
パスをに変更しますC:\\Documents and Settings\\user\\Desktop\\xxx.txt
。
C:\ Documents and Settings \ user \ Desktop/xxx.txtを使用してみてください
C:\ Documents and Settings \ user \ Desktop\xxx.txtの代わりに