当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.IsFileLocked方法代码示例

本文整理汇总了C#中System.IO.FileInfo.IsFileLocked方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.IsFileLocked方法的具体用法?C# FileInfo.IsFileLocked怎么用?C# FileInfo.IsFileLocked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了FileInfo.IsFileLocked方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

        public static Map Read(string file)
        {
            if (!File.Exists(file))
            {
                Write(file, new Map());
                return new Map();
            }
            else
            {
                FileInfo inf = new FileInfo(file);
                while (inf.IsFileLocked()) { Console.WriteLine("Wait..."); };
                try
                {
                    using (Stream s = File.Open(file, FileMode.Open))
                    {
                        System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(Map));
                        return (Map)reader.Deserialize(s);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.GetBaseException().ToString());
                    return new Map();
                }

            }
        }
开发者ID:iceriver102,项目名称:alta-mtc-version-2,代码行数:27,代码来源:Map.cs

示例2: checkFileFunctionThread

 private void checkFileFunctionThread(object obj)
 {
     while (true)
     {
         if (setting.DateFile > 0)
         {
             List<string> fileRecord = Directory.GetFiles(setting.Folder, "*.mp4", SearchOption.AllDirectories).ToList();
             if (fileRecord != null && fileRecord.Count > 0)
             {
                 foreach (string file in fileRecord)
                 {
                     FileInfo inf = new FileInfo(file);
                     if (inf.Exists && inf.CreationTime.Date < DateTime.Now.Date)
                     {
                         double day = (DateTime.Now.Date - inf.CreationTime.Date).TotalDays;
                         if (day > setting.DateFile && !inf.IsFileLocked())
                         {
                             inf.Delete();
                         }
                     }
                 }
             }
         }
         Thread.Sleep(24 * 3600 * 1000);
     }
 }
开发者ID:iceriver102,项目名称:alta-mtc-version-2,代码行数:26,代码来源:App.xaml.cs

示例3: Cleanup

        protected override void Cleanup()
        {
            base.Cleanup();

            var fi = new FileInfo(_testName + ".database.catIndex.location");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:11,代码来源:SecondaryIndexTests.cs

示例4: Cleanup

        void Cleanup()
        {
            var fi = new FileInfo(_testName + ".database");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:9,代码来源:DatabaseCacheTests.cs

示例5: Cleanup

        protected virtual void Cleanup()
        {
            var fi = new FileInfo(_testName + ".xml");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".index");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".test.index");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".database");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".database.index");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".subscriber.database");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".subscriber.database.index");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".subscriber.database");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".subscriber.database.index");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".catalog.indexUpdate");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".scenario");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".database.catIndex.index");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();

            fi = new FileInfo(_testName + ".database.cascade.index");
            if (fi.Exists)
                while (fi.IsFileLocked())
                    Thread.Sleep(100);

            fi.Delete();
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:93,代码来源:FileTest.cs


注:本文中的System.IO.FileInfo.IsFileLocked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。