} /* CreateDir */ public static bool NtfsUserPermise(string WebAppPath, string[] Directorys, out string msg) { msg = ""; System.OperatingSystem osvi = WinSys.GetWindowVersion(); if (osvi.Version.Major < 5)//非NT系统//dwMajorVersion { msg = "错误,非NT系统!"; return(false); } if (Directorys == null || Directorys.Length == 0) { return(true); } foreach (string dir in Directorys) { if (dir.Trim(new char[] { ' ', '\t' }).Length == 0) { continue; } if (!Directory.Exists(WebAppPath + "\\" + dir)) { Directory.CreateDirectory(WebAppPath + "\\" + dir); } NtfsUserPermise(WebAppPath + "\\" + dir, out msg); } return(true); }
public static bool NtfsUserPermise(string dirpath, out string msg) { msg = ""; System.OperatingSystem osvi = WinSys.GetWindowVersion(); if (osvi.Version.Major < 5)//非NT系统//dwMajorVersion { msg = "错误,非NT系统!"; return(false); } if (dirpath == null || dirpath.Length == 0) { return(true); } if (!Directory.Exists(dirpath)) { return(true); } if (osvi.Version.MinorRevision == 0)//2000//dwMinorVersion { try { NtfsUserPermissions.SetDirPermission(dirpath, "ASPNET"); NtfsUserPermissions.SetDirPermission(dirpath, "Everyone"); } catch (Exception ee) { msg = ee.Message; return(false); } } else { try { NtfsUserPermissions.SetDirPermission(dirpath, "NETWORK SERVICE"); NtfsUserPermissions.SetDirPermission(dirpath, "Everyone"); } catch (Exception ee) { msg = ee.Message; return(false); } } return(true); }