3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Path.Combine(a, b, c)をUnityで

Posted at

C#のSystem.IO.PathにはCombineというメソッドがあります。
これは2つのパスを合成するメソッドで
Path.Combine("Hoge", "Foo.txt");
とするとHoge/Foo.txtを返してくれます。

Path.Combine("Hoge/", "Foo.txt");
でも同じ結果を返してくれるので便利です。

ただ、3つ以上のパスを合成する場合
Path.Combine(a, b, c);
と書けるのは.Net 4以降です。

Unityは.Net 2なので、そのままでは書けませんが、Linqを使うと簡単に書けます。
new[] { a, b, c }.Aggregate(Path.Combine);

benri✌('ω')✌

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?