c# - 保存布局到流。错误:找不到部分路径“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:\TreeListLayout\
- 即目录名称。删除尾部斜杠或附加文件名
推荐阅读
- javascript - 如何使用 XMLHttpRequest 解决或屏蔽 Chrome 扩展的“SameSite”cookie 错误
- time-series - 为什么某些时间序列模型(ARIMA、BATS、ETS)会为预测生成平线?
- embedded - 扩展 u-boot 功能
- java - 如何使用底部导航视图处理 MainActivity 上另一个片段的侦听器?
- google-cloud-storage - terraform中的base64编码的md5哈希?
- github - 配置 Travis CI 以构建新的 github 分支
- ios - 使用 Swift 解析嵌套 JSON 数据的正确方法是什么?
- python - 使用 pdb 调试 tox python 测试?
- python - 如何使用全息视图可视化时间跨度?
- jsp - 为什么我不能使用动态键(jsp、jstl、el)访问我的 HashMap 的值?