首页 > 解决方案 > 保存布局到流。错误:找不到部分路径“c:\TreeListLayout\”

问题描述

我尝试运行一个示例 -链接
用户 - 管理员
场景:
  - 我展开树列表节点;
  - 我执行“SaveLayoutToStream_mtd()”方法;

我排队

System.IO.FileStream outFile = new System.IO.FileStream(fileName, System.IO.FileMode.Create);

一个错误

System.IO.DirectoryNotFoundException:“找不到部分路径”c:\TreeListLayout\“。”

所有代码

string fileName = @"c:\TreeListLayout\";
public void SaveLayoutToStream_mtd()
{            
    System.IO.FileStream outFile = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
    treeList1.SaveLayoutToStream(outFile);
    outFile.Close();
}

如何修复错误?

标签: c#winformsdevexpress

解决方案


你看到你的代码和你引用的例子之间的区别了吗?您正在尝试使用无效名称写入文件c:\TreeListLayout\- 即目录名称。删除尾部斜杠或附加文件名


推荐阅读