Exemplo n.º 1
0
        public static void MoveFile(Recordset <EfsEntry> rs, int idFile, int idNewParent, string strNewName)
        {
            rs.filterFindEqual("id", idFile);
            if (!rs.applyFilter())
            {
                throw new FileNotFoundException();
            }

            EfsEntry ee = EfsEntry.NewFile(idNewParent, strNewName);

            rs.cursor.UpdateFields(ee, "idParent", "name");
            // rs.cursor.UpdateFields( ee, "idParent", "name", "dtAccess" );
        }
Exemplo n.º 2
0
        public static EfsEntry AddFile(Recordset <EfsEntry> rs, int idParent, iFileIo io, string sourcePath, out long cbBytes)
        {
            FileInfo fi = new FileInfo(sourcePath);

            if (!fi.Exists)
            {
                throw new FileNotFoundException();
            }

            // Overwrite the old one
            int?idExisting = FindFile(rs, idParent, fi.Name);

            if (idExisting.HasValue)
            {
                DeleteFile(rs, idExisting.Value);
            }

            using (var trans = rs.session.BeginTransaction())
            {
                // Create a new one.
                var ne = EfsEntry.NewFile(idParent, fi);
                rs.cursor.Add(ne);
                trans.LazyCommitAndReopen();

                // Copy the data.
                rs.filterFindEqual("id", ne.id);
                ne = rs.getFirst();

                using (var stm = ne.data.Write(rs.cursor))
                    cbBytes = io.Read(stm, sourcePath);

                trans.Commit();

                return(ne);
            }
        }