Cristi
Cristi
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
Okay thank you a lot <3
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
Thank you all SO, SOOOO much! ❤️
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
I finally managed to get it working exacly how I wanted it
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
this line of code saved my god damn live you have no idea how fricking thankful I am
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
omg i finally managed to do it
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
at this point I have tried everything and nothing works
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
like I seriously tried everything if you could help me id mean the world to me
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
but why? how can I make them asyncronious??
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
It's ok thank you a lot
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
i changed it again and made the FileList_SelectionChanged function async and instead of getSelectionSize().Result I did await getSelectionSize() and it still didn't work
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
it should work but it doesn't and I have no clue why
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
The main logic is here string getReadableSize(long sib) { string[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB" }; int i = 0; double size = sib; while (size >= 1024 && i < sizeSuffixes.Length - 1) { size /= 1024; i++; } return $"{size:0.##} {sizeSuffixes[i]}"; } string getSelectedItemExtension() { foreach (StackPanel item in FileList.SelectedItems) { if (item.Children[1] is Label label) { string path = Path.Combine(CurrentPath, label.Content.ToString()); if(File.Exists(path)) return new FileInfo(path).Extension; else if(Directory.Exists(path)) return "Folder"; } } return null; } async Task<long> getDirSize(string path) { long res = 0; try { foreach (string file in Directory.GetFiles(path)) res += new FileInfo(file).Length; foreach (string dir in Directory.GetDirectories(path)) res += await getDirSize(dir); } catch{} return res; } async Task<string> getSelectionSize() { long res = 0; foreach(StackPanel item in FileList.SelectedItems) { if (item.Children[1] is Label label) { string path = Path.Combine(CurrentPath,label.Content.ToString()); if(Directory.Exists(path)) res += await getDirSize(path); else if(File.Exists(path)) res += new FileInfo(path).Length; } } return getReadableSize(res); } void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (FileList.SelectedItems.Count == 0) { CurrentItemSize = "Size: --"; CurrentItemType = "Type: --"; } else { CurrentItemSize = "Size: Calculating..."; CurrentItemSize = getSelectionSize().Result; if (FileList.SelectedItems.Count == 1) CurrentItemType = $"Type: {getSelectedItemExtension()}"; else CurrentItemType = "Type: --"; } }
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
@🧨 New Years Mayor McCheese 🧨 I'm sorry for the ping but I added the async and Task logic but it still doesn't work, my application freezes after I select an item until it's done calculating the size, what did I do wrong?
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
you have no idea how much it means to me
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
thank you so much though
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
oh okay I'll try it, I'm sorry but right now I have to go to sleep so I really gotta go
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
sorry it's like the second time im using git as well lol
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
can you acces it
81 replies
CC#
Created by Cristi on 12/28/2023 in #help
Background Worker giving exceptions.
i think i did it
81 replies