繁体   English   中英

如何使用Microsoft.Win32.SaveFileDialog保存文件名超过MAX_PATH的文件?

[英]How to save files using Microsoft.Win32.SaveFileDialog with filenames longer than MAX_PATH?

我正在尝试保存文件:

Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog
        {
            FileName = "verylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexampleverylongexample.foo",
            DefaultExt = ".foo",
            Filter = "Foo Bar|*.foo"
        };

在对话框中按“保存”后,我收到以下消息:

The filename, directory name, or volume label syntax is incorrect.

即使我的app.manifest有此内容:

<application xmlns="urn:schemas-microsoft-com:asm.v3">
  <windowsSettings xmlns:ws2="https://schemas.microsoft.com/SMI/2016/WindowsSettings">
      <ws2:longPathAware>
          true
      </ws2:longPathAware>
</windowsSettings>

如此处所述: https : //docs.microsoft.com/zh-cn/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation

因此,是的,评论中提到的人表示您的Windows不支持它。

从Windows 10 版本1607开始 ,MAX_PATH限制已从常见的Win32文件和目录功能中删除。

现在,要使其跨Windows,您必须创建自定义文件对话框,并使用\\\\?\\Drive:\\样式通过路径进行操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM