Click here to Skip to main content
15,905,563 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF editor is duplicating my image files Pin
Dave Kreskowiak17-Dec-22 5:25
mveDave Kreskowiak17-Dec-22 5:25 
QuestionCustomizing the TabPanel section of the TabControl (simple solution found) Pin
Maximilien15-Dec-22 4:33
Maximilien15-Dec-22 4:33 
QuestionWPF .Net Core Dependency Injection & View Models Pin
Kevin Marois14-Dec-22 12:06
professionalKevin Marois14-Dec-22 12:06 
AnswerRe: WPF .Net Core Dependency Injection & View Models Pin
Graeme_Grant31-Dec-22 3:15
mvaGraeme_Grant31-Dec-22 3:15 
Question(ANSWERED) (newbie) I'm confused about ListView ItemSource bindings. Pin
Maximilien8-Dec-22 2:42
Maximilien8-Dec-22 2:42 
AnswerRe: (newbie) I'm confused about ListView ItemSource bindings. Pin
Richard Deeming8-Dec-22 3:58
mveRichard Deeming8-Dec-22 3:58 
GeneralRe: (newbie) I'm confused about ListView ItemSource bindings. Pin
Maximilien8-Dec-22 4:22
Maximilien8-Dec-22 4:22 
Questionfast directory infos for a lot of files Pin
pitwi6-Dec-22 2:14
pitwi6-Dec-22 2:14 
I'm writing a WPF (C#) app for my MP3 collection with more then 350,000 files.
I'm reading path and filenames directly from the HD and store the infos in a SQLite Database.
Because of reorganizationes I have to do that in periodic intervals.
But the current code needs 17 hours (!!!) for that. I'm sure there must be a faster way.
Does anyone have an idea?


private void ButtonImport_Click(object sender, RoutedEventArgs e)
{
    // Import

    string initdir = @"H:\mp3\";

    Cursor cu = this.Cursor;
    this.Cursor = Cursors.Wait;
    string errtxt = "";
    // delete all existing database entries
    ToolStripStatusLabel1.Text = "deleting ..."
    try
    {
        SQLiteCommand dbCom = new SQLiteCommand("DELETE FROM Dateien", dbConn);
        dbCom.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "delete error", MessageBoxButton.OK, MessageBoxImage.Error);
        return;
    }
    sPfad = initdir;
    // import
    DateTime t1 = DateTime.Now;
    int z = 0;
    loopDir(sPfad);
    DateTime t2 = DateTime.Now;
    txt = "";
    txt += z.ToString() + " files saved in ";
    txt += ((t2 - t1).TotalSeconds / 60).ToString("0.0") + " min.";
    txt += errtxt != "" ? Environment.NewLine + Environment.NewLine + errtxt : "";
    this.Cursor = cu;
    MessageBox.Show(txt, "Import", MessageBoxButton.OK, MessageBoxImage.Information);
}


private void loopDir(string strPath)
{
    // read directories and files
    string dn = "";
    DirectoryInfo ofs = new DirectoryInfo(strPath);
    bool f = false;
    int n = 0;
    try
    {
        n = ofs.GetDirectories().Length;
    }
    catch (Exception ex)
    {
        f = true;
        errtxt += ex.Message + Environment.NewLine;
    }
    if (f == false)
    {
        foreach (DirectoryInfo d in ofs.GetDirectories())
        {
            dn = strPath + "\\" + d.Name;
            dn = dn.Replace("\\\\", "\\");
            loopDir(dn);  // recursive call
        }
        // file loop
        bool ok = false;
        foreach (FileInfo fl in ofs.GetFiles())
        {
            ok = false;
            for (int i = 0; i < fext.Length; i++)   // only files with spec. extensions
            {
                if (fl.Name.ToLower().EndsWith(fext[i]))
                    ok = true;
            }
            if (ok == true)
            {
                string sqls = "";
                sqls += "INSERT INTO Dateien (Pfad, Datei) VALUES (";
                sqls += "'" + sqlready(strPath).ToString().Substring(2) + "\\', ";
                sqls += "'" + sqlready(fl.Name) + "')";
                try
                {
                    SQLiteCommand dbCom = new SQLiteCommand(sqls, dbConn);
                    dbCom.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "database save error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                z++;
            }
        }
    }
}


Thanks
AnswerRe: fast directory infos for a lot of files Pin
pitwi6-Dec-22 2:29
pitwi6-Dec-22 2:29 
GeneralRe: fast directory infos for a lot of files Pin
Dave Kreskowiak6-Dec-22 5:40
mveDave Kreskowiak6-Dec-22 5:40 
AnswerRe: fast directory infos for a lot of files Pin
Richard Deeming6-Dec-22 2:51
mveRichard Deeming6-Dec-22 2:51 
GeneralRe: fast directory infos for a lot of files Pin
pitwi6-Dec-22 6:56
pitwi6-Dec-22 6:56 
QuestionCustom Control Styling Pin
Kevin Marois2-Dec-22 8:58
professionalKevin Marois2-Dec-22 8:58 
AnswerRe: Custom Control Styling Pin
Richard Deeming5-Dec-22 0:27
mveRichard Deeming5-Dec-22 0:27 
GeneralRe: Custom Control Styling Pin
Kevin Marois5-Dec-22 12:15
professionalKevin Marois5-Dec-22 12:15 
GeneralRe: Custom Control Styling Pin
Richard Deeming5-Dec-22 21:57
mveRichard Deeming5-Dec-22 21:57 
GeneralRe: Custom Control Styling Pin
Kevin Marois5-Dec-22 13:57
professionalKevin Marois5-Dec-22 13:57 
GeneralRe: Custom Control Styling Pin
Kevin Marois5-Dec-22 14:10
professionalKevin Marois5-Dec-22 14:10 
QuestionWPF .Net Core Relay Command with Parameters Pin
Kevin Marois1-Dec-22 13:50
professionalKevin Marois1-Dec-22 13:50 
QuestionForgot Password Pin
Kevin Marois1-Dec-22 13:06
professionalKevin Marois1-Dec-22 13:06 
AnswerRe: Forgot Password Pin
Richard Deeming1-Dec-22 22:10
mveRichard Deeming1-Dec-22 22:10 
QuestionWPF Core Hyperlkink Custom Control Pin
Kevin Marois29-Nov-22 16:29
professionalKevin Marois29-Nov-22 16:29 
AnswerRe: WPF Core Hyperlkink Custom Control Pin
Richard Deeming29-Nov-22 21:59
mveRichard Deeming29-Nov-22 21:59 
GeneralRe: WPF Core Hyperlkink Custom Control Pin
Kevin Marois30-Nov-22 5:46
professionalKevin Marois30-Nov-22 5:46 
GeneralRe: WPF Core Hyperlkink Custom Control Pin
Richard Deeming30-Nov-22 21:25
mveRichard Deeming30-Nov-22 21:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.