程序数据。拒绝访问(VB.NET 2008)

程序数据。拒绝访问(VB.NET 2008),vb.net,access-denied,programdata,Vb.net,Access Denied,Programdata,我正在ProgramData中存储.dat文件,以写入和读取有关我的软件的配置。我会读,但不会写。安装软件时会复制这些.dat文件。已使用AwInstall创建安装程序 要写入.DAT的代码: 错误: 我得到这个错误: System.UnauthorizedAccessException: Acceso denegado a la ruta de acceso 'C:\ProgramData\NameSoftware\Configuration\paramsBiz.dat'. en Sys

我正在ProgramData中存储.dat文件,以写入和读取有关我的软件的配置。我会读,但不会写。安装软件时会复制这些.dat文件。已使用AwInstall创建安装程序

要写入.DAT的代码:

错误: 我得到这个错误:

System.UnauthorizedAccessException: Acceso denegado a la ruta de acceso 'C:\ProgramData\NameSoftware\Configuration\paramsBiz.dat'.
   en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   en System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   en System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   en System.IO.StreamWriter.CreateFile(String path, Boolean append)
   en System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   en System.IO.StreamWriter..ctor(String path)
更新1: 好的,正如Hans Passant所说,这个目录ProgramData有问题吗


但是,可以使用其他路径来存储数据,并且无论是否是管理员,任何用户都可以读取和写入这些文件?

这是完全正常的,程序只能以只读方式访问ProgramData。一个相当空的目录,除了拼写词典之外没有其他内容。您必须改用AppData。Users/Default/AppData/Local/[folder software]/对所有用户都是通用的?存储数据库的安全路径是什么?使用读写权限或使用此目录c:/Users/Public/保存配置文件和数据库会更好?位置取决于桌面上是否有单个登录的I用户-如果有,用户的AppData就可以了。”“公共”不是一个好主意——所有用户都更好,但很难找到。我只想在C:\MyApp\上为应用程序创建一个文件夹。。。
System.UnauthorizedAccessException: Acceso denegado a la ruta de acceso 'C:\ProgramData\NameSoftware\Configuration\paramsBiz.dat'.
   en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   en System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   en System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   en System.IO.StreamWriter.CreateFile(String path, Boolean append)
   en System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   en System.IO.StreamWriter..ctor(String path)