WPF:隔离存储文件路径太长
我正在使用 ClickOnce 部署我的 WPF 应用程序。在 Visual Studio 中进行本地开发时,我通过调用 IsolatedStorageFile.GetUserStoreForDomain()
将文件存储在独立存储中。这工作得很好,生成的路径是
C:\Users\Frederik\AppData\Local\IsolatedStorage\phqduaro.crw\hux3pljr.cnx\StrongName.kkulk3wafjkvclxpwvxmpvslqqwckuh0\Publisher.ui0lr4tpq53mz2v2c0uqx21xze0w22gq\Files\FilerefData\-5817501 16(189 个字符)
但是当我使用 ClickOnce 部署我的应用程序时,生成的路径太长,导致创建隔离存储目录时出现DirectoryNotFoundException
。用ClickOnce生成的路径是:
C:\Users\Frederik\AppData\Local\Apps\2.0\Data\OQ0LNXJT.R5V\8539ABHC.ODN\exqu..tion_e07264ceafd7486e_0001.0000_b8f01b38216164a0\Data\StrongName.wy0cojdd3mpvq45404l3g xdklugoanvi\Publisher.ui0lr4tpq53mz2v2c0uqx21xze0w22gq\Files\FilerefData\- 581750116(247 个字符)
当我浏览文件夹时,除了路径的最后一个目录之外的所有文件夹都存在。然后,当尝试在此位置创建文件夹时,Windows 告诉我无法创建目录,因为生成的路径名太长。
如何缩短IsolatedStorage生成的路径?
I'm deploying my WPF app with ClickOnce. When developing locally in Visual Studio, I store files in the isolated storage by calling IsolatedStorageFile.GetUserStoreForDomain()
. This works just fine and the generated path is
C:\Users\Frederik\AppData\Local\IsolatedStorage\phqduaro.crw\hux3pljr.cnx\StrongName.kkulk3wafjkvclxpwvxmpvslqqwckuh0\Publisher.ui0lr4tpq53mz2v2c0uqx21xze0w22gq\Files\FilerefData\-581750116 (189 chars)
But when I deploy my app with ClickOnce, the generated path becomes too long, resulting in a DirectoryNotFoundException
when creating the isolated storage directory. The generated path with ClickOnce is:
C:\Users\Frederik\AppData\Local\Apps\2.0\Data\OQ0LNXJT.R5V\8539ABHC.ODN\exqu..tion_e07264ceafd7486e_0001.0000_b8f01b38216164a0\Data\StrongName.wy0cojdd3mpvq45404l3gxdklugoanvi\Publisher.ui0lr4tpq53mz2v2c0uqx21xze0w22gq\Files\FilerefData\-581750116 (247 chars)
When I browse the folders all but the last directory of the path exists. Then when trying to create a folder at this location windows tells me I can't create a directory because the resulting path name will be too long.
How can I shorten the path generated by the IsolatedStorage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现这是 Windows 文件系统的限制(大约 250 个字符限制),您无法选择或配置独立存储的路径。
我通过将隔离存储范围从域更改为应用程序来“解决”了问题......这不完全是最好的解决方案,但目前它可以
well i found out it's a limitation of the windows filesystem (around 250 characters limit) and you can't choose or configure the path of the isolated store.
i 'fixed' the problem by changing the isolated storage scope from domain to application... not exactly the best solution but for now it'll do