2
I am using windows server 2008 and IIS 6.1, I have a service that needs to access files in a certain directory, but I do not have access.
What I need to configure to get access?
After adding Administrator
as the user, the application says that the directory does not exist.
List<FileInfo> files = new List<FileInfo>();
if (Directory.Exists(@"C:\Users\Administrator\Documents\MovieCollector\PacotesSerializados"))
{
foreach (string file in Directory.GetFiles(dataFilePath))
{
FileInfo fileInfo = new FileInfo(file);
files.Add(fileInfo);
}
}
else
{
throw new Exception(dataFilePath+ " não lexiste");
}
files.Sort((x, y) => y.CreationTime.CompareTo(x.CreationTime));
if (files.Count == 0)
{
throw new Exception("Lista vazia");
}
If you have any users who have access to this directory, you can give permission to the user who runs on IIS. Or I’m still not sure if this is how it works in this version of IIS, but you can define the user you want to connect your application to in IIS, in IIS8 is the option "Connect as...", so there set a user with the privileges in the directory in question. (Maybe it’s a similar option (I don’t have an IIS 6.1, to test))
– Fernando Leal
I added
Administrator
as the user, but says that the directory does not exist. I added an image that shows the error in the client and the directory on the server.– Italo Pessoa
What code is executed to generate the specified exception?
– Leonel Sanches da Silva
Added the code used to recover the files.
– Italo Pessoa
Have you tried adding the group
everyone
with reading and writing in this directory?– Leonel Sanches da Silva