Exemple #1
0
        public static byte[] ReadFile(IOConnectionInfo ioc)
        {
            Stream       sIn = null;
            MemoryStream ms  = null;

            try
            {
                sIn = IOConnection.OpenRead(ioc);
                if (sIn == null)
                {
                    return(null);
                }

                ms = new MemoryStream();
                MemUtil.CopyStream(sIn, ms);

                return(ms.ToArray());
            }
            catch (Exception) { }
            finally
            {
                if (sIn != null)
                {
                    sIn.Dispose();
                }
                if (ms != null)
                {
                    ms.Dispose();
                }
            }

            return(null);
        }
Exemple #2
0
            public static LockFileInfo Load(IOConnectionInfo iocLockFile)
            {
                Stream s = null;

                try
                {
                    s = IOConnection.OpenRead(iocLockFile);
                    if (s == null)
                    {
                        return(null);
                    }
                    StreamReader sr  = new StreamReader(s, StrUtil.Utf8);
                    string       str = sr.ReadToEnd();
                    sr.Dispose();
                    if (str == null)
                    {
                        Debug.Assert(false); return(null);
                    }

                    str = StrUtil.NormalizeNewLines(str, false);
                    string[] v = str.Split('\n');
                    if ((v == null) || (v.Length < 6))
                    {
                        Debug.Assert(false); return(null);
                    }

                    if (!v[0].StartsWith(LockFileHeader))
                    {
                        Debug.Assert(false); return(null);
                    }
                    return(new LockFileInfo(v[1], v[2], v[3], v[4], v[5]));
                }
                catch (FileNotFoundException) { }
                catch (Exception) { Debug.Assert(false); }
                finally { if (s != null)
                          {
                              s.Dispose();
                          }
                }

                return(null);
            }
Exemple #3
0
        /// <summary>
        /// Load a KDB file from a file.
        /// </summary>
        /// <param name="strFilePath">File to load.</param>
        /// <param name="kdbFormat">Format specifier.</param>
        /// <param name="slLogger">Status logger (optional).</param>
        public void Load(string strFilePath, KdbxFormat kdbFormat, IStatusLogger slLogger)
        {
            IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFilePath);

            Load(IOConnection.OpenRead(ioc), kdbFormat, slLogger);
        }