- 教材写 AppDomain.CurrentDomain.BaseDirectory + "Camera\\",Linux 上反斜杠会成为文件名的一部分 - 编译时把传给 System.IO(File、Directory、Path、各种 Stream)和 Image / Bitmap 读写文件方法的 路径参数包上 Sim.Host.WindowsPaths.Fix;只包语义上确实是这些方法里名字带 path / file / dir 的 字符串参数,不换行,编辑器里看到的仍是原代码 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 lines
548 B
C#
14 lines
548 B
C#
using System.ComponentModel;
|
|
|
|
namespace Sim.Host;
|
|
|
|
/// <summary>
|
|
/// Windows 写法的路径(教材里常见 BaseDirectory + "Camera\\")在 Linux 上要把反斜杠换成斜杠,否则反斜杠成了文件名的一部分。
|
|
/// 编译时把学生代码里传给文件、文件夹、图片读写方法的路径参数包上这个方法(见 Sim.Runner/PathRewriter.cs)。
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public static class WindowsPaths
|
|
{
|
|
public static string Fix(string path) => path?.Replace('\\', '/')!;
|
|
}
|