Devastorian
Displaying Images in .NET application, that are out of project folder.
public class ImageCopyService
{
public void CopyPngImages(string sourceFolder, string destinationFolder)
{
// Zkontrolujte, zda zdrojová složka existuje
if (!Directory.Exists(sourceFolder))
{
Console.WriteLine("Zdrojová složka neexistuje.");
return;
}
// Projděte všechny soubory s příponou ".png" ve zdrojové složce
string[] pngFiles = Directory.GetFiles(sourceFolder, "*.png");
foreach (string filePath in pngFiles)
{
// Získání názvu souboru z cesty
string fileName = Path.GetFileName(filePath);
Console.WriteLine(fileName);
// Vytvoření cesty pro cílovou složku
string destinationPath = Path.Combine(destinationFolder, fileName);
// Kopírování souboru do cílové složky
File.Copy(filePath, destinationPath, true);
}
}
}
20 replies
Displaying Images in .NET application, that are out of project folder.
Well, I already had to do some backloops to have that excel work as I intended, also they can edit it while the app is running, so my app has to load it all again every 5 minutes or so 😄
20 replies
Displaying Images in .NET application, that are out of project folder.
Well, that is a problem, because this is a app that is developed for a company that does not want normal conventional database, so it uses excel as a "database" and the pictures are somewhere inside a directory on windows server. The app is running locally and the data from excel are being loaded normally, maybe I could try to connect the directories somehow, so they mirror each other? Or write a code, that copies all the images from that one directory to my root directory?
20 replies
✅ How can I read and edit .XLSX files in C# (WPF)
Here is a tutorial, that worked for me. Only problem is, that office needs to be installed for this to work. Also it is needed to close the workbook after being done with the worksheet or else the book will get locked. https://stardevstudio.com/csharp/how-to-read-excel-files-in-csharp/?mwg_rnd=8606258
90 replies
✅ How can I read and edit .XLSX files in C# (WPF)
parsing the whole sheet into an multidimensional array might be even worse, but that would mean, that I dont have to be connected to that XLSX constantly, just read it once and work with the data
90 replies