Exemple #1
0
        private static void SaveFingerPrint(String destFileName, FingerPrint fingerPrint)
        {
            String fingerPrintFileName = FileDownloadHelper.MakeFingerPrintFilePath(destFileName);

            SecurityElement finger_print = new SecurityElement("finger_print");

            finger_print.AddAttribute("time_stamp", fingerPrint.timeStamp);
            finger_print.AddAttribute("file_size", fingerPrint.fileSize.ToString());

            File.WriteAllText(fingerPrintFileName, finger_print.ToString());
        }
Exemple #2
0
        private static FingerPrint LoadFingerPrint(String destFileName)
        {
            String fingerPrintFileName = FileDownloadHelper.MakeFingerPrintFilePath(destFileName);

            if (!File.Exists(fingerPrintFileName))  //记录文件尚未创建
            {
                return new FingerPrint {
                           timeStamp = "", fileSize = 0
                }
            }
            ;

            try
            {
                SecurityElement xmlDoc = SecurityElement.FromString(File.ReadAllText(fingerPrintFileName));

                String timeStamp = xmlDoc.Attributes["time_stamp"].ToString();
                Int64  fileSize  = Int64.Parse(xmlDoc.Attributes["file_size"].ToString());
                return(new FingerPrint {
                    timeStamp = timeStamp, fileSize = fileSize
                });
            }
            catch (IOException)
            {
                return(new FingerPrint {
                    timeStamp = "", fileSize = 0
                });
            }
            catch (System.IO.IsolatedStorage.IsolatedStorageException)
            {
                return(new FingerPrint {
                    timeStamp = "", fileSize = 0
                });
            }
            catch (XmlSyntaxException)
            {
                return(new FingerPrint {
                    timeStamp = "", fileSize = 0
                });
            }
            catch (FormatException)
            {
                return(new FingerPrint {
                    timeStamp = "", fileSize = 0
                });
            }
            catch (NullReferenceException)
            {
                return(new FingerPrint {
                    timeStamp = "", fileSize = 0
                });
            }
        }
Exemple #3
0
        private static void DeleteDestFile(String destFileName)
        {
            File.Delete(FileDownloadHelper.MakeFingerPrintFilePath(destFileName));

            File.Delete(destFileName);
        }