示例#1
0
文件: Data.cs 项目: obisan/Multislice
        public bool Store()
        {
            if (data == null)
            {
                return(false);
            }
            FileRW fN;
            string lwd;

            lwd = Path.GetDirectoryName(FileName);
            if (!Directory.Exists(lwd))
            {
                try
                {
                    Directory.CreateDirectory(lwd);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Can't create directory " + lwd + ":\n" + e.ToString());
                    return(false);
                }
            }
            if ((fN = FileRW.Open(FileName, FileRW.Action.CreateAlways, FileRW.Access.Write)) != null)
            {
                uint nw;
                nw = fN.Write(data, length);
                fN.Close();
                if (nw != length)
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
文件: Data.cs 项目: obisan/Multislice
        public bool Restore()
        {
            if (data == null)
            {
                return(false);
            }
            FileRW fN;

            if ((fN = FileRW.Open(FileName, FileRW.Action.Open, FileRW.Access.Read)) != null)
            {
                uint nw;
                nw = fN.Read(data, length);
                fN.Close();
                if (nw != length)
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }