예제 #1
0
        private void packageDir(SQLite db, string dir,string pdir)
        {
            var files = Directory.EnumerateFileSystemEntries(dir.ToString());
            foreach (var fileName in files)            
            {
                FileInfo finfo = new FileInfo(fileName);
                string vpath = pdir + "/" + finfo.Name;
                
                if (finfo.Attributes.HasFlag(FileAttributes.Directory))
                {
                    packageDir(db, fileName, vpath);
                }
                else
                {
                    Console.WriteLine("package "+ fileName + " >> " + vpath);
                    int len = (int) finfo.Length;
                    byte[] buf;
                    using (var fs = finfo.OpenRead())
                    {          
                        buf = new byte[len];
                        fs.Read(buf, 0, len);
                    }

                    db.bindString(1, vpath.ToString());
                    db.bindBlob(2, buf);
                    db.bindLong(3, timestamp(finfo.LastWriteTime));
                    db.execute();
                    db.reset();
                }
            }            
        }