473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

saving files so any user can access them

I have an application that loads several files from a database (as byte[])
then writes them to the "docs and settings\all users\application data\my
company\my app" folder.

The problem I'm running into is that if I'm logged into windows (domain
admin) and perform actions that result in files being saved they aren't
accessible by other users when the login.
The files that the application saves to disk aren't user specific, they are
application wide. It seems that I need to do something like save the files
with "Guest" privileges. That way anyone can access, modify and delete
them.

Is this the best solution or is there something else I could be doing? I
don't want to use a different location if I don't have to, I would rather
somehow clear the permissions or set a generic permission.

I've found some information on impersonation, but that sounds a little heavy
duty to simply make a file accessible by everyone.

Any suggestions or help greatly appreciated,
Steve
Nov 2 '07 #1
2 1380
Steve,

I can think of two options.

The first is to use isolated storage, getting a file using the machine
store for the application through the static GetMachineStoreForApplication
method on the IsolatedStorageFile class.

The second is to keep the file where it is, but change the permissions
to make sure it is accessible by everyone. Basically, you will have to get
the FileInfo and DirectoryInfo instances for the directory and files,
respectively, and call the GetAccessControl methods on them, getting the
FileSecurity and DirectorySecurity instances from them and modifying the
permissions through those.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sklett" <s@s.comwrote in message
news:Of**************@TK2MSFTNGP04.phx.gbl...
>I have an application that loads several files from a database (as byte[])
then writes them to the "docs and settings\all users\application data\my
company\my app" folder.

The problem I'm running into is that if I'm logged into windows (domain
admin) and perform actions that result in files being saved they aren't
accessible by other users when the login.
The files that the application saves to disk aren't user specific, they
are application wide. It seems that I need to do something like save the
files with "Guest" privileges. That way anyone can access, modify and
delete them.

Is this the best solution or is there something else I could be doing? I
don't want to use a different location if I don't have to, I would rather
somehow clear the permissions or set a generic permission.

I've found some information on impersonation, but that sounds a little
heavy duty to simply make a file accessible by everyone.

Any suggestions or help greatly appreciated,
Steve

Nov 2 '07 #2
Nicholas,
Thank you for the reply, that worked perfect!

<code>
FileInfo fileInfo = new FileInfo(path);
FileSecurity fileSecurity = fileInfo.GetAccessControl();
fileSecurity.AddAccessRule(new FileSystemAccessRule(
"Users",
FileSystemRights.FullControl,
AccessControlType.Allow) );

fileInfo.SetAccessControl(fileSecurity);
</code>

Have a good weekend,
Steve
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:uf**************@TK2MSFTNGP04.phx.gbl...
Steve,

I can think of two options.

The first is to use isolated storage, getting a file using the machine
store for the application through the static GetMachineStoreForApplication
method on the IsolatedStorageFile class.

The second is to keep the file where it is, but change the permissions
to make sure it is accessible by everyone. Basically, you will have to
get the FileInfo and DirectoryInfo instances for the directory and files,
respectively, and call the GetAccessControl methods on them, getting the
FileSecurity and DirectorySecurity instances from them and modifying the
permissions through those.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sklett" <s@s.comwrote in message
news:Of**************@TK2MSFTNGP04.phx.gbl...
>>I have an application that loads several files from a database (as byte[])
then writes them to the "docs and settings\all users\application data\my
company\my app" folder.

The problem I'm running into is that if I'm logged into windows (domain
admin) and perform actions that result in files being saved they aren't
accessible by other users when the login.
The files that the application saves to disk aren't user specific, they
are application wide. It seems that I need to do something like save the
files with "Guest" privileges. That way anyone can access, modify and
delete them.

Is this the best solution or is there something else I could be doing? I
don't want to use a different location if I don't have to, I would rather
somehow clear the permissions or set a generic permission.

I've found some information on impersonation, but that sounds a little
heavy duty to simply make a file accessible by everyone.

Any suggestions or help greatly appreciated,
Steve


Nov 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

138
by: theodp | last post by:
--> From http://www.techdirt.com/articles/20040406/1349225.shtml Microsoft Patents Saving The Name Of A Game Contributed by Mike on Tuesday, April 6th, 2004 @ 01:49PM from the...
2
by: steve | last post by:
Hello, I am trying to import an image file into a form. This would be a persons picture saved in the same directory for every unique record. I don't have any problems making an action button to...
4
by: Kenny ODell | last post by:
I am fairly new to the C# world, and I am seeking a little guidance about saving user information. Consider the following: I have several windows which contain settings for an embedded target. ...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
6
by: (PeteCresswell) | last post by:
User wants to go this route instead of storing pointers in the DB and the documents outside. Only time I tried it was with only MS Word docs - and that was a loooong time ago - and it seemed to...
2
by: Michael | last post by:
We have an ASP.NET 2.0 web application running on a Windows 2003 domain controller. Part of that application needs to read and write files from and to a network share ( living on a MAC Xserveraid)...
2
by: chiefsitebuilder | last post by:
I have a question about saving an MS Access program to CD and verifyng that the program works after being saved. Here is my situation, I have a person who developed an application for me using...
3
by: Nathan Guill | last post by:
I have an interface that works with an Access back-end. I would like to store and/or load user defined query strings per each user (i.e. no user can access another's queries). The idea I had was...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.