C# ZipFile条目FullName文件夹斜线有时'\';有时'/';转向

C# ZipFile条目FullName文件夹斜线有时'\';有时'/';转向,c#,C#,我使用一个方法来获取ZipFile中的FullName属性 public static string GetAllFullName(string zipPath) { string s = ""; using (ZipArchive archive = ZipFile.OpenRead(zipPath)) { foreach (ZipArchiveEntry entry in archive.Entries) { s

我使用一个方法来获取ZipFile中的FullName属性

public static string GetAllFullName(string zipPath)
{
    string s = "";
    using (ZipArchive archive = ZipFile.OpenRead(zipPath))
    {
        foreach (ZipArchiveEntry entry in archive.Entries)
        {
            s += entry.FullName + "\n";
        }
    }
    return s;
}

string s = GetAllFullName(zipPath);
//save the string to SaveFilePath File(such as txt)
File.WriteAllText(SaveFilePath, s, Encoding.Default);
然后我可以在一个zip中看到所有的全名

在我的例子中,我从其他人那里得到一个zipfile并打印全名,结果是(所有结果的一部分)

然后我将文件解压到一个文件夹中,选择“所有文件”,然后右键单击use winrar以再次压缩到.zip

然后我打印zip文件(所有结果的一部分)

我找到了斜线变化的方向(这条线表示文件夹,与常规文件夹相同)

为什么同样的zipfile通过这样做可以改变线的方向

我现在所做的需要识别全名来做一些事情,但是如果方向可以像这样改变

这会导致一个大问题,因为如果我通过“/”添加全名,可能其他人会执行一些压缩操作,并且方向会改变,因此我添加的内容将无法识别


出现这种情况的原因是什么?如何确定何时转向以及转向哪个方向?

路径分隔符取决于平台。在.NET中,使用System.IO.Path.DirectorySpeparatorChar和System.IO.Path.AltDirectorySpeparatorChar查看哪些是有效的。大多数现代操作系统外壳现在都可以接受这两种格式,例如,当我在windows 8.1资源管理器中输入“c:/windows”时,它会正确地扩展到c:\windows。路径分隔符取决于平台。在.NET中,使用System.IO.Path.DirectorySpeparatorChar和System.IO.Path.AltDirectorySpeparatorChar查看哪些是有效的。大多数现代操作系统外壳现在都可以同时接受这两种模式,例如,当我在windows 8.1资源管理器中输入“c:/windows”时,它会正确地扩展到c:\windows。
Telerik.Windows.Controls.dll
Telerik.Windows.Controls.Input.dll
WMS.Silverlight.Languages.dll
zh-Hans\System.Windows.Data.resources.dll
Assets\AppMenu.xml
Assets\Configuration.xml
Assets\Resource.xml
Image\Lock16.png
Telerik.Windows.Controls.dll
Telerik.Windows.Controls.Input.dll
WMS.Silverlight.Languages.dll
Assets/
Assets/AppMenu.xml
Assets/Configuration.xml
Assets/Resource.xml
dlls/
dlls/System.Windows.Controls.Extensions.dll
Image/
Image/Lock16.png
Image/Login.png
Image/WMS_Login_bar.png
Image/WMS_Logo_s.png