public File(DirectoryInfo file, DriveMapping mapping, User user) { Extension = file.Extension; Type = "Directory"; Name = file.Name + (file.Name.Contains(file.Extension) ? "" : file.Extension); try { Permissions = UserFileAccessRights.Get(file.FullName).ToPerms(); } catch { } FileIcon fi; if (FileIcon.TryGet(Extension, out fi)) { Type = fi.Type; Name = Name.Remove(Name.LastIndexOf(file.Extension)); } Icon = "../images/icons/" + ParseForImage(file); if (Icon.EndsWith(".ico")) { Icon = "../api/mycomputer/" + ParseForImage(file); } if (file.Extension.ToLower().Equals(".png") || file.Extension.ToLower().Equals(".jpg") || file.Extension.ToLower().Equals(".jpeg") || file.Extension.ToLower().Equals(".gif") || file.Extension.ToLower().Equals(".bmp") || file.Extension.ToLower().Equals(".wmf")) { Icon = "../api/mycomputer/thumb/" + HttpUtility.UrlEncode(Converter.UNCtoDrive(file.FullName, mapping, user).Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|2f", "/"); } CreationTime = file.CreationTime.ToShortDateString() + " " + file.CreationTime.ToString("hh:mm"); UnderlyingCreation = file.CreationTime; ModifiedTime = file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToString("hh:mm"); UnderlyingModified = file.LastWriteTime; UnderlyingSize = 0; Size = ""; Path = HttpUtility.UrlEncode(Converter.UNCtoDrive(file.FullName, mapping, user).Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|5c", "\\"); Permissions = UserFileAccessRights.Get(file.FullName).ToPerms(); }
public File(FileInfo file, DriveMapping mapping, User user) { Extension = file.Extension; Type = "File"; Name = file.Name + (file.Name.Contains(file.Extension) ? "" : file.Extension); CreationTime = file.CreationTime.ToShortDateString() + " " + file.CreationTime.ToString("hh:mm"); UnderlyingCreation = file.CreationTime; ModifiedTime = file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToString("hh:mm"); UnderlyingModified = file.LastWriteTime; Size = parseLength(file.Length); UnderlyingSize = file.Length; FileIcon fi; if (FileIcon.TryGet(Extension, out fi)) { Type = fi.Type; Name = Name.Remove(Name.LastIndexOf(file.Extension)); } if (Type == "File") { try { RegistryKey rkRoot = Registry.ClassesRoot; string keyref = rkRoot.OpenSubKey(file.Extension).GetValue("").ToString(); Type = rkRoot.OpenSubKey(keyref).GetValue("").ToString(); Name = Name.Remove(Name.LastIndexOf(file.Extension)); } catch { Type = "File"; } } if (Type != "File") { Icon = "../images/icons/" + ParseForImage(file); if (Icon.EndsWith(".ico")) { Icon = "../api/mycomputer/" + ParseForImage(file); } } else { Icon = "../images/icons/file.png"; } string m = Converter.UNCtoDrive2(file.FullName, mapping, user); Path = "../Download/" + HttpUtility.UrlEncode(m.Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|2f", "/"); if (file.Extension.ToLower().Equals(".png") || file.Extension.ToLower().Equals(".jpg") || file.Extension.ToLower().Equals(".jpeg") || file.Extension.ToLower().Equals(".gif") || file.Extension.ToLower().Equals(".bmp") || file.Extension.ToLower().Equals(".wmf")) { Icon = "../api/mycomputer/thumb/" + HttpUtility.UrlEncode(m.Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|2f", "/"); } Permissions = UserFileAccessRights.Get(file.FullName).ToPerms(); }
public Properties(FileInfo file, DriveMapping mapping, User user) { Actions = isWriteAuth(mapping) ? HAP.MyFiles.AccessControlActions.Change : HAP.MyFiles.AccessControlActions.View; Name = file.Name + (file.Name.Contains(file.Extension) ? "" : file.Extension); Extension = file.Extension; DateCreated = file.CreationTime.ToString(); DateModified = file.LastWriteTime.ToString(); DateAccessed = file.LastAccessTime.ToString(); Location = HttpUtility.UrlEncode(Converter.UNCtoDrive(file.Directory.FullName, mapping, user).Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|5c", "\\"); Size = File.parseLength(file.Length); FileIcon fi; if (FileIcon.TryGet(Extension, out fi)) { Type = fi.Type; } if (Type == "File") { try { RegistryKey rkRoot = Registry.ClassesRoot; string keyref = rkRoot.OpenSubKey(file.Extension).GetValue("").ToString(); Type = rkRoot.OpenSubKey(keyref).GetValue("").ToString(); } catch { Type = "File"; } } if (Type != "File") { Icon = "../images/icons/" + File.ParseForImage(file); if (Icon.EndsWith(".ico")) { Icon = "../api/mycomputer/" + File.ParseForImage(file); } } else { Icon = "../images/icons/file.png"; } }