public static void UpgradeFileSystem(string oldOS, string newOS) { switch (oldOS) { case "95": if (newOS == "98" || newOS == "2000" || newOS == "ME") { // We are upgrading from the old WinClassic file System to the new WinClassic filesystem! // All the above OSes share basically the same file layout! // (Excluding Documents And Settings) which is 2000 and ME only // Add Address Book into existance! SaveDirectoryInfo(ProfileProgramsDirectory, "Outlook Express", false, "Outlook Express", true); CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Outlook Express"), "WAB.exe", "addressbook", 8, 512); // There is no "The Microsoft Network" folder! if (Directory.Exists(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"))) { Directory.Delete(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"), true); } FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject <FileSystemFolderInfo>(File.ReadAllText(Path.Combine(ProfileProgramsDirectory, "_data.info"))); foreach (THDirInfo dir in fsfi.SubDirs) { if (dir.Name == "The Microsoft Network") { fsfi.SubDirs.Remove(dir); break; } } } break; } }
public static void RefreshDesktopIcons(ListViewItem[] baseIcons, ref ListView view, string folder) { view.Items.Clear(); // This resets it to it's default view.Items.AddRange(baseIcons); foreach (string dir in Directory.GetDirectories(folder)) { string label = ReadDataFile(dir); view.Items.Add(label ?? Path.GetFileName(dir), 1); view.FindItemWithText(Path.GetFileName(dir)).Tag = dir; } foreach (string dir in Directory.GetFiles(folder)) { if (Path.GetFileName(dir) != "_data.info") { THFileInfo file = new THFileInfo(); FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject <FileSystemFolderInfo>(File.ReadAllText(Path.Combine(folder, "_data.info"))); foreach (THFileInfo f in fsfi.Files) { if (f.Name.ToLower() == Path.GetFileName(dir).ToLower()) { file = f; break; } } if (new FileInfo(dir).Extension == ".exe" && file.FileIcon == 8) { file.FileIcon = 10; } if (new FileInfo(dir).Extension == ".txt" && file.FileIcon == 8) { file.FileIcon = 12; } view.Items.Add(Path.GetFileName(dir), file.FileIcon); view.FindItemWithText(Path.GetFileName(dir)).Tag = dir; string toWrite = JsonConvert.SerializeObject(fsfi, Formatting.Indented); File.WriteAllText(Path.Combine(folder, "_data.info"), toWrite); } } }
public static string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) { string Val = ""; string directoryFileInfo = File.ReadAllText(Path.Combine(reqDirectory, "_data.info")); FileSystemFolderInfo toRead = JsonConvert.DeserializeObject <FileSystemFolderInfo>(directoryFileInfo); if (returnYesIfProtected) { if (toRead.IsProtected) { return("yes"); } } else { return(toRead.Label); } return(Val); }
public static void SaveDirectoryInfo(string parent, string dirname, bool isProtected, string label, bool allowback) { if (File.Exists(Path.Combine(parent, dirname, "_data.info")) && Path.Combine(parent, dirname) != ProfileFileSystemDirectory) { return; } Directory.CreateDirectory(Path.Combine(parent, dirname)); FileSystemFolderInfo info = new FileSystemFolderInfo(); info.IsProtected = isProtected; info.Label = label; info.DOSLabel = info.Label.ToUpper().Replace("*", "").Replace("+", "").Replace(":", "").Replace(";", "").Replace(".", "").Replace(" ", ""); if (info.DOSLabel.Length > 8) { info.DOSLabel = info.DOSLabel.Substring(0, 6) + "~1"; } if (label == "C:") { info.DOSLabel = "C:"; } info.AllowBack = allowback; info.Files = new List <THFileInfo>(256); info.SubDirs = new List <THDirInfo>(256); info.ByteSize = 0; if (parent != ProfileDirectory) { FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject <FileSystemFolderInfo>(File.ReadAllText(Path.Combine(parent, "_data.info"))); THDirInfo thd = new THDirInfo(); thd.Name = info.Label; thd.DOSName = info.DOSLabel; fsfi.SubDirs.Add(thd); File.WriteAllText(Path.Combine(parent, "_data.info"), JsonConvert.SerializeObject(fsfi, Formatting.Indented)); } string toWrite = JsonConvert.SerializeObject(info, Formatting.Indented); File.WriteAllText(Path.Combine(Path.Combine(parent, dirname), "_data.info"), toWrite); }
public static void UpdateDirectoryInfo(string path, THFileInfo newfile) { newfile.DOSName = newfile.Name.ToUpper().Replace("*", "").Replace("+", "").Replace(":", "").Replace(";", "").Replace(" ", ""); if (newfile.DOSName.Contains(".")) { string[] dos = newfile.DOSName.Split('.'); if (dos.Count() > 2) { List <string> dosb = dos.ToList(); dosb.RemoveRange(1, dos.Count() - 2); dos = dosb.ToArray(); } dos[1] = dos[1].Substring(0, 3); if (dos[0].Length > 8) { dos[0] = dos[0].Substring(0, 6) + "~1"; } newfile.DOSName = dos[0] + "." + dos[1]; } else if (newfile.DOSName.Length > 8) { newfile.DOSName = newfile.DOSName.Substring(0, 6) + "~1"; } if (File.ReadAllText(Path.Combine(path, "_data.info")).Contains(newfile.DOSName)) { return; } FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject <FileSystemFolderInfo>(File.ReadAllText(Path.Combine(path, "_data.info"))); fsfi.Files.Add(newfile); fsfi.ByteSize += newfile.ByteSize; string toWrite = JsonConvert.SerializeObject(fsfi, Formatting.Indented); File.WriteAllText(Path.Combine(path, "_data.info"), toWrite); }