Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用多平台程序的斜杠或反斜杠_C#_Windows_Web_Path_Operating System - Fatal编程技术网

C# 使用多平台程序的斜杠或反斜杠

C# 使用多平台程序的斜杠或反斜杠,c#,windows,web,path,operating-system,C#,Windows,Web,Path,Operating System,我正在构建一个在windows上处理图像的服务,并且有一个web部件。 我知道windows使用反斜杠来分隔雇工和其他人使用的 斜线为了在web部件上显示我的图像,我必须使用斜杠作为我的相对(到项目文件夹)图像路径(或者我是吗?),当我想使用web单击删除照片时,我必须为系统提供完整路径,因此我得到了这个“混合路径”: C:\Users\source\repos\ImageService\ImageServiceWeb\to/2017/10/20171001\u 150622.jpg 其中Ima

我正在构建一个在windows上处理图像的服务,并且有一个web部件。 我知道windows使用反斜杠来分隔雇工和其他人使用的 斜线为了在web部件上显示我的图像,我必须使用斜杠作为我的相对(到项目文件夹)图像路径(或者我是吗?),当我想使用web单击删除照片时,我必须为系统提供完整路径,因此我得到了这个“混合路径”:

C:\Users\source\repos\ImageService\ImageServiceWeb\to/2017/10/20171001\u 150622.jpg

其中ImageServiceWeb目录是我的项目目录。 当我在Visual Studio 2017上使用此命令时,令我惊讶的是: System.IO.File.Delete(photo.FullPath); 它实际上删除了图像,并没有引发异常。 它是如何发生的,为什么会发生?
谢谢

windows在将win32路径转换为nt路径时替换为\。因此,我们可以在pathWindows API中使用/将“/”转换为“\”,作为将名称转换为NT样式名称的一部分,但使用“\?\”前缀时除外,如以下各节所述。-从…起