addTrailingSlash() public static méthode

public static addTrailingSlash ( string s ) : string
s string
Résultat string
Exemple #1
0
        private void OnFolderRenamed(object source, RenamedEventArgs e)
        {
            // TODO Fix rename in database
            this.fileDatabase.renameFolderPaths(Utils.addTrailingSlash(e.OldFullPath), Utils.addTrailingSlash(e.FullPath));

            Debug.WriteLine("Rename folder: " + e.FullPath + " " + e.ChangeType);
            // TODO
        }
Exemple #2
0
        public void addFileToDB(FileInfo fi)
        {
            /****
             *  New DB	Existing DB
             *  One statement                                   (new DB)    (existing data)
             *          INSERT REPLACE	                        929ms	    1013ms
             *  is slower then tw
             *          SELECT => nothing, INSERT or UPDATE	    570ms	    549ms
             *
             * Tested single line statement: SQLiteCommand insertSQL = new SQLiteCommand("INSERT OR IGNORE INTO FileNodes (path, parentpath, created, modified, size) VALUES (@path, @pathHash, @parentPathHash, @created, @modified, @size) ", this.dbConnector.connection);
             *****/
            if (this.readOnly)
            {
                return;
            }

            SQLiteCommand command;

            command = new SQLiteCommand("SELECT id, created, modified, size FROM `FileNodes` WHERE path = @path LIMIT 1 COLLATE NOCASE;", this.dbConnector.connection);
            command.Parameters.AddWithValue("@path", fi.FullName);
            SQLiteDataReader reader = command.ExecuteReader();
            DataTable        dt     = new DataTable();

            //try {
            dt.Load(reader);
            //} catch (System.InvalidOperationException ioe) {
            //MessageBox.Show("addFileToDB " + e.Message);
            // ToDo debug and work out exceptions that can occur here
            //  return;
            //}
            bool executeNonQuery = false;

            if (dt.Rows.Count > 0)
            {
                if ((DateTime)dt.Rows[0]["created"] < fi.CreationTime ||
                    (DateTime)dt.Rows[0]["modified"] < fi.LastWriteTime ||
                    (long)dt.Rows[0]["size"] != fi.Length)
                {
                    command = new SQLiteCommand("UPDATE `FileNodes` SET `created` = @created, `filename` = @filename, `modified` = @modified, `size` = @size, `metainfoindexed` = 0 WHERE `id` = @id", this.dbConnector.connection);
                    command.Parameters.AddWithValue("@id", (long)dt.Rows[0]["id"]);
                    executeNonQuery = true;
                }
            }
            else
            {
                command = new SQLiteCommand("INSERT INTO FileNodes (`path`, `parentpath`, `filename`, `created`, `modified`, `size`) " +
                                            "VALUES (@path,  @parentpath,  @filename,  @created,  @modified,  @size) ", this.dbConnector.connection);
                command.Parameters.AddWithValue("@path", fi.FullName);
                // Add trailing slash so we can filter on complete paths ('c:\test\' won't match 'c:\testing\')
                command.Parameters.AddWithValue("@parentpath", Utils.addTrailingSlash(fi.DirectoryName));
                executeNonQuery = true;
            }
            if (executeNonQuery)
            {
                command.Parameters.AddWithValue("@created", fi.CreationTime);
                command.Parameters.AddWithValue("@modified", fi.LastWriteTime);
                command.Parameters.AddWithValue("@filename", fi.Name);
                command.Parameters.AddWithValue("@size", fi.Length);
                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                command.ExecuteNonQuery();
                sw.Stop();
                //Debug.WriteLine(DBConnector.ToReadableString(command) + " " + sw.ElapsedMilliseconds + "ms");
                this.filterOutOfDate++;
            }
        }
Exemple #3
0
 private void OnFolderDeleted(object source, FileSystemEventArgs e)
 {
     this.fileDatabase.purgeMatchingParentPaths(Utils.addTrailingSlash(e.FullPath));
     this.showProgress();
 }