Cross-platform file name handling in .NET Core

前端 未结 6 1442
我在风中等你
我在风中等你 2020-12-15 03:02

How to handle file name in System.IO classes in a cross-platform manner to make it work on Windows and Linux?

For example, I write this code that works

6条回答
  •  盖世英雄少女心
    2020-12-15 03:25

    You can also use Path.DirectorySeparatorChar as below:

     Console.WriteLine("..{0}Data{0}uploads{0}{{filename}}", Path.DirectorySeparatorChar);
    

    Reference: MSDN

提交回复
热议问题