CreateTextFile with RW access for all users

  • Thread starter Thread starter troy anderson
  • Start date Start date
T

troy anderson

How do you invoke System.IO.File.CreateText such that all users may have
read and write access to this file? I have tried
{
string RemoteConfigFile =
System.IO.Path.GetDirectoryName(Application.ExecutablePath) +
"\\Settings\\Remoting.config";

System.Security.Permissions.FileIOPermission FA = new
System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.AllAccess,
RemoteConfigFile);

System.IO.StreamWriter Writer = System.IO.File.CreateText(RemoteConfigFile);

}

But it does not work.

I appreciate the help
 
How do you invoke System.IO.File.CreateText such that all users may have
read and write access to this file?

Ideally you place it under x:\Documents and Settings\All
Users\Application Data\ which is the location designed to hold files
shared by all users. You can use
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
to get the path.




Mattias
 
Back
Top