コード例 #1
0
        public static string WipeDir(string _fileDir)
        {
            //Write to wallet file
            String FileFolder = _fileDir + CandyStore.GetParameters().FileFolder;


            if (!Directory.Exists(FileFolder))
            {
                //Create directory if it does not exist
                return("Folder does not exist, no wipe could be performed");
            }

            //Delete storage folder
            try
            {
                var list = Directory.GetFiles(FileFolder, "*");

                if (list.Length > 0)
                {
                    for (int i = 0; i < list.Length; i++)
                    {
                        File.Delete(list[i]);
                    }
                }

                return("Wipe completed");
            }
            catch
            {
                return("Wipe failed");
            }
        }
コード例 #2
0
        public static void WriteBin(byte[] _storage, string _saveAsUniqueId, string _fileDir)
        {
            //Write to wallet file
            String FileFolder = _fileDir + CandyStore.GetParameters().FileFolder;
            String FilePath   = FileFolder + _saveAsUniqueId + ".bin";

            if (!Directory.Exists(FileFolder))
            {
                //Create directory if it does not exist
                Directory.CreateDirectory(FileFolder);
            }

            BinaryWriter writer = new BinaryWriter(File.Open(FilePath, FileMode.Create));

            writer.Write(_storage);  //Write binaries
            writer.Close();
        }
コード例 #3
0
        public static PassObject ReadBlobToObject(string _readAsUniqueId, string _fileDir)
        {
            //Read from bin
            string filePath = _fileDir + CandyStore.GetParameters().FileFolder + _readAsUniqueId + ".bin";

            if (!File.Exists(filePath))
            {
                throw new Exception("Filepath does not exist");
            }

            byte[] BlobData = ReadBin(filePath);

            MemoryStream    memorystreamd      = new MemoryStream(BlobData);
            BinaryFormatter bfd                = new BinaryFormatter();
            PassObject      deserializedobject = bfd.Deserialize(memorystreamd) as PassObject;

            memorystreamd.Close();

            return(deserializedobject);
        }
コード例 #4
0
        public static string RemoveStorageSpecific(string _fileDir, string _websiteUniqueID)
        {
            //Write to wallet file
            string filePath = _fileDir + CandyStore.GetParameters().FileFolder + _websiteUniqueID + ".bin";

            if (!File.Exists(filePath))
            {
                throw new Exception("File does not exist");
            }

            //Delete storage folder
            try
            {
                File.Delete(filePath);

                return("Removal completed");
            }
            catch
            {
                return("Removal failed");
            }
        }