Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
のようなパス文字列がありますがc:\user\test\test.jpg、どうすれば作成できc:\\user\\test\\test.jpgますか?
c:\user\test\test.jpg
c:\\user\\test\\test.jpg
これを試して:
string path = @"c:\user\test\test.jpg";
string s = s.Replace(@"\", @"\\");
コードで文字列リテラルを使用している場合にのみ、エスケープが必要になります。とにかく自動エスケープが必要なのはなぜですか。エスケープを必要としないリテラルの前に @ を使用できます。