|
6 | 6 |
|
7 | 7 | namespace GrabWindows10LockScreenPictures { |
8 | 8 | class Program { |
| 9 | + static readonly string App_Folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Grab Windows 10 Lock Screen Pictures"; |
9 | 10 | static void Main(string[] args) { |
10 | | - string[] users = File.ReadAllLines(Path.GetFullPath("Data/locations.txt")); |
11 | | - string saved = @$"C:\Users\{users.FirstOrDefault()}\Pictures\Spotlight Images"; |
12 | | - |
13 | 11 | try { |
14 | | - foreach (string name in users) { |
15 | | - GetPics(@$"C:\Users\{name}\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", saved); |
| 12 | + string userName = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).Replace(@"C:\Users\", ""); |
| 13 | + |
| 14 | + if (!Directory.Exists(App_Folder)) { |
| 15 | + Directory.CreateDirectory(App_Folder); |
| 16 | + File.WriteAllText(Path.Combine(App_Folder, "locations.txt"), userName); |
16 | 17 | } |
17 | 18 |
|
18 | | - PopTheToast.PopIt("All images were successfully saved."); |
| 19 | + if (File.Exists(Path.Combine(App_Folder, "locations.txt"))) { |
| 20 | + string[] users = File.ReadAllLines(Path.Combine(App_Folder, "locations.txt")); |
| 21 | + string saved = @$"C:\Users\{users.FirstOrDefault()}\Pictures\Spotlight Images"; |
| 22 | + |
| 23 | + foreach (string name in users) { |
| 24 | + GetPics(@$"C:\Users\{name}\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", saved); |
| 25 | + } |
| 26 | + |
| 27 | + PopTheToast.PopIt("All images were successfully saved."); |
| 28 | + } else { |
| 29 | + PopTheToast.PopIt("Error: locations.txt file was not found."); |
| 30 | + } |
19 | 31 | } catch (Exception ex) { |
20 | 32 | PopTheToast.PopIt("An error occurred: " + ex.Message); |
21 | 33 | } |
|
0 commit comments