|
4 | 4 | using System.IO; |
5 | 5 | using System.Linq; |
6 | 6 |
|
7 | | -namespace GrabWindows10LockScreenPictures { |
8 | | - class Program { |
9 | | - static readonly string App_Folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Grab Windows 10 Lock Screen Pictures"; |
| 7 | +namespace GrabWindows10LockScreenPictures; |
10 | 8 |
|
11 | | - static void Main(string[] args) { |
12 | | - try { |
13 | | - string userName = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).Replace(@"C:\Users\", ""); |
| 9 | +class Program { |
| 10 | + static readonly string App_Folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Grab Windows 10 Lock Screen Pictures"; |
14 | 11 |
|
15 | | - if (!Directory.Exists(App_Folder)) { |
16 | | - Directory.CreateDirectory(App_Folder); |
17 | | - File.WriteAllText(Path.Combine(App_Folder, "locations.txt"), userName); |
18 | | - } |
| 12 | + static void Main(string[] args) { |
| 13 | + try { |
| 14 | + string userName = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).Replace(@"C:\Users\", ""); |
19 | 15 |
|
20 | | - if (File.Exists(Path.Combine(App_Folder, "locations.txt"))) { |
21 | | - string[] users = File.ReadAllLines(Path.Combine(App_Folder, "locations.txt")); |
22 | | - string saved = @$"C:\Users\{users.FirstOrDefault()}\Pictures\Spotlight Images"; |
| 16 | + if (!Directory.Exists(App_Folder)) { |
| 17 | + Directory.CreateDirectory(App_Folder); |
| 18 | + File.WriteAllText(Path.Combine(App_Folder, "locations.txt"), userName); |
| 19 | + } |
23 | 20 |
|
24 | | - foreach (string name in users) { |
25 | | - GetPics(@$"C:\Users\{name}\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", saved); |
26 | | - } |
| 21 | + if (File.Exists(Path.Combine(App_Folder, "locations.txt"))) { |
| 22 | + string[] users = File.ReadAllLines(Path.Combine(App_Folder, "locations.txt")); |
| 23 | + string saved = @$"C:\Users\{users.FirstOrDefault()}\Pictures\Spotlight Images"; |
27 | 24 |
|
28 | | - PopTheToast.PopIt("All images were successfully saved."); |
29 | | - } else { |
30 | | - PopTheToast.PopIt("Error: locations.txt file was not found."); |
| 25 | + foreach (string name in users) { |
| 26 | + GetPics(@$"C:\Users\{name}\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", saved); |
31 | 27 | } |
32 | | - } catch (Exception ex) { |
33 | | - PopTheToast.PopIt("An error occurred: " + ex.Message); |
| 28 | + |
| 29 | + PopTheToast.PopIt("All images were successfully saved."); |
| 30 | + } else { |
| 31 | + PopTheToast.PopIt("Error: locations.txt file was not found."); |
34 | 32 | } |
| 33 | + } catch (Exception ex) { |
| 34 | + PopTheToast.PopIt("An error occurred: " + ex.Message); |
35 | 35 | } |
| 36 | + } |
36 | 37 |
|
37 | | - static void GetPics(string assets, string saved) { |
38 | | - foreach (string file in Directory.GetFiles(assets).Where(f => new FileInfo(f).Length > 200 * 1024)) { |
39 | | - Image img = Image.FromFile(file); |
40 | | - if (img.Width > img.Height) { |
41 | | - string newFile = saved + file.Replace(assets, "") + ".jpg"; |
42 | | - File.Copy(file, newFile, true); |
43 | | - } |
| 38 | + static void GetPics(string assets, string saved) { |
| 39 | + foreach (string file in Directory.GetFiles(assets).Where(f => new FileInfo(f).Length > 200 * 1024)) { |
| 40 | + Image img = Image.FromFile(file); |
| 41 | + if (img.Width > img.Height) { |
| 42 | + string newFile = saved + file.Replace(assets, "") + ".jpg"; |
| 43 | + File.Copy(file, newFile, true); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
|
0 commit comments