I would like to get the file owner information but are having some trouble with this line:
const string fileOwner = Delimon.Win32.IO.File.GetAccessControl(fi.Name).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
Specifically, it doesn't like fi.name
. My error is
An object reference is required for the non-static field, method, or property 'Delimon.Win32.IO.File.GetAccessControl(string)'
Here is the larger chuck of code where it sits:
// check if file exists. if so dont overwrite...
if(Delimon.Win32.IO.File.Exists(targetPath+fi.Name)) {
// Console.WriteLine(fileName + " already exists, nothing written");
}
else {
// Console.WriteLine(fileName + " is new so written to dir");
string fileOwner=Delimon.Win32.IO.File.GetAccessControl(fi.Name).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
Delimon.Win32.IO.File.Copy(fileName, destFile, true);
// convert extension to number
switch(fileExt) {
case ".doc":
fileType=1;
break;
case ".xls":
fileType=2;
break;
case ".mdb":
fileType=3;
break;
default:
fileType=1;
break;
}
// I want tot use fileOwner here in an SQL statement
}
Please note fi.Name
holds the file name only. I also have a variable called fileName
which holds the full absolute path including the file name. This gives me the same issue.