c# - How to store C# SpecialFolder path into SQLite database?
问题描述
I am working on a WPF app and I am stuck in a tricky problem.
There is a TEXT
field called "OutputFolder" into SQLite database which stores different folder paths (as name suggests its folder where some output is generated).
I want to save special folder path (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
) into SQLite
database in "OutputFolder".
Actual value I want to store in database
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\temp";
I have no option to use any other directory or something else. Its very clear that I have to store this path into database.
I am open to add new column to specify any flag value or anything that identify path as special folder.
解决方案
据我了解 - 您需要存储两种类型的绝对路径和一种包含特殊文件夹的路径。问题是如何识别一种路径,然后相应地处理它。
如果您无法更改 db 数据结构(添加其他字段),那么可能是将有关特殊文件夹的信息注入路径的一种方法。
例如,您可以使用无效(用于路径)字符来标记注入的开始和结束。您的路径应如下所示:
var injectedPath = "?5?\\temp";
当然,在阅读时,您必须进行解析,如果发现注入,则将其替换为真实路径。在我们的例子中 MyDocuments = 5 参见Environment.SpecialFolder。
推荐阅读
- java - 如何在java中以ISO日期格式打印当前时间和日期?
- php - php for 循环处理每个迭代
- python - 如何根据变量更改不和谐命令
- python-3.x - 如何使用 pyqtgraph 和 pyqt5 在烛台中设置轴间隔?
- python - 如何通过 python Tkinter 关闭其他窗口?
- java - Imageview不采用cardview的角半径
- javascript - SAPUI5 - 选择框的动态 odata 绑定
- python - 如何限制django-rest-framework-api上传的格式(post方式)
- mysql - 使用 mysql 更新表贡献计算的触发器
- laravel - 在 RouteAction.php 第 84 行:无效的路由操作