我可以将文本文件保存到应用程序目录吗? [英] Can I save text files to application directory?

查看:62
本文介绍了我可以将文本文件保存到应用程序目录吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个新问题,基于较旧帖子的回复.我需要保存一个值
当我的应用首次运行时,将适用于所有
用户 登录到PC并使用我的应用程序.该设置仅在当时是已知的
安装的范围,因此具有应用程序或用户范围的应用程序设置为
不适合的.建议我将设置保存到外部文件并保存/读取
根据需要.显而易见的选择是将文件保存到项目中
应用程序路径(保持整洁).测试期间一切正常
但是当将应用程序安装在PC上时,应用程序路径变为
C:\ program files \应用程序名称\ etc.当我尝试执行该代码时
保存文件后,出现权限被拒绝错误.我知道这是一部分
UAC控件的功能,但何时可以接受以编程方式停止开发人员
在自己的应用程序文件夹中创建文件?此设置不变
每个用户,并且应用程序范围的应用程序设置只能在运行时读取
时间.那我应该在哪里存储该文件?

This is a new question based on the response from an older post. I needed to save a value
when my app is run for the first time that would be applicable to all users who
logon to the PC and use my application. The setting is only known at the time
of the install so Application settings with application or user scope are
unsuitable. I was advised to save the setting to an external file and save/read
it as needed. The obvious choice was to save the file to the projects
application path (keeping things tidy). Everything worked fine during testing
but when the application is installed on a PC, the application path becomes
C:\program files\ application name\etc. When I try to execute the code that
saves the file, I get a permissions denied error. I understand that it's part
of the UAC control but when did it become acceptable to stop developers programmatically
creating files in their own application folder? This setting does not change
per user, and the application scoped application settings are read only at run
time. So where am I supposed to store this file?

推荐答案

如何使用Common Application Data文件夹:

How about using the Common Application Data folder:

Dim CommonAppDataPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)



这篇关于我可以将文本文件保存到应用程序目录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆