Пример #1
0
 public static bool HasAds(string path)
 {
     if (!SupportsAds(path))
     {
         return(false);
     }
     using (var sh = Kernel32Util.CreateFileForRead(path)) {
         return(!sh.IsInvalid);
     }
 }
Пример #2
0
        public static string LoadAds(string path)
        {
            if (!SupportsAds(path))
            {
                return(null);
            }

            using (var sh = Kernel32Util.CreateFileForRead(path)) {
                if (sh.IsInvalid)
                {
                    return(null);
                }
                using (var stream = new StreamReader(new FileStream(sh, FileAccess.Read))) {
                    return(stream.ReadToEnd());
                }
            }
        }
Пример #3
0
        public static bool UpdateAds(string path, string data)
        {
            if (!SupportsAds(path))
            {
                return(false);
            }

            using (var sh = Kernel32Util.CreateFileForWrite(path)) {
                if (sh.IsInvalid)
                {
                    return(false);
                }
                using (var stream = new StreamWriter(new FileStream(sh, FileAccess.Write))) {
                    stream.Write(data);
                    return(true);
                }
            }
        }