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


C# FileInfo.IsDirectory方法代码示例

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


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

示例1: NetflixDataModel

		public NetflixDataModel(FileInfo dataDirectory)
		{
			if (dataDirectory == null) 
            {
				throw new ArgumentNullException("dataDirectory is null");
			}
			if (!dataDirectory.Exists || !dataDirectory.IsDirectory()) 
            {
				throw new FileNotFoundException(dataDirectory.toString());
			}

			log.Info("Creating NetflixDataModel for directory: " + dataDirectory);

			log.info("Reading movie data...");
			List<NetflixMovie> movies = ReadMovies(dataDirectory);

			log.info("Reading preference data...");
			List<User> users = ReadUsers(dataDirectory, movies);

			log.Info("Creating delegate DataModel...");
			_delegate = new GenericDataModel(users);
		}
开发者ID:ccollie,项目名称:taste.net,代码行数:22,代码来源:NetflixDataModel.cs

示例2: ScanFile

        /// <summary>
        /// Get last modified time on a single file or recurse if
        /// the file is a directory. 
        /// </summary>
        /// <param name="f">file or directory</param>
        /// <param name="scanInfoMap">map of filenames to last modified times</param>
        void ScanFile(FileInfo f, Dictionary<string, long> scanInfoMap)
        {
            if (IsStopping || IsStopped)
            {
                // stop if no longer running
                return;
            }

            try
            {
                if (!f.Exists)
                    return;

                if (!f.IsDirectory())
                {
                    if ((_filter == null) || ((_filter != null) && _filter.Accept(f.Directory, f.Name)))
                    {
                        string name = f.FullName;
                        long lastModified = f.LastWriteTimeUtc.Ticks;
                        scanInfoMap.Add(name, lastModified);
                    }
                }
                else if (f.IsDirectory() && (_recursive || _scanDirs.Contains(f)))
                {
                    FileInfo[] files = (new DirectoryInfo(f.FullName)).GetFiles();
                    for (int i = 0; i < files.Length; i++)
                    {
                        if (IsStopping || IsStopped)
                        {
                            // stop if no longer running
                            return;
                        }
                        ScanFile(files[i], scanInfoMap);
                    }
                }
            }
            catch (IOException e)
            {
                Log.Warn("Error scanning watched files", e);
            }
        }
开发者ID:patricknharris,项目名称:njetty,代码行数:47,代码来源:Scanner.cs

示例3: PrescanTwoTrees

        internal void PrescanTwoTrees()
        {
            var visitor = new AbstractIndexTreeVisitor
                              {
                                  VisitEntryAux = (treeEntry, auxEntry, indexEntry, file) =>
                                                   {
                                                       if (treeEntry is Tree || auxEntry is Tree)
                                                       {
                                                           throw new ArgumentException("Can't pass me a tree!");
                                                       }

                                                       ProcessEntry(treeEntry, auxEntry, indexEntry);
                                                   },

                                  FinishVisitTree = (tree, auxTree, currentDirectory) =>
                                                        {
                                                            if (currentDirectory.Length == 0) return;
                                                            if (auxTree == null) return;

                                                            if (_index.GetEntry(currentDirectory) != null)
                                                            {
                                                                Removed.Add(currentDirectory);
                                                            }
                                                        }
                              };

            new IndexTreeWalker(_index, _head, _merge, _root, visitor).Walk();

            // if there's a conflict, don't list it under
            // to-be-removed, since that messed up our next
            // section
            Removed.RemoveAll(removed => Conflicts.Contains(removed));

            foreach (string path in _updated.Keys)
            {
                if (_index.GetEntry(path) == null)
                {
                    FileSystemInfo file = new FileInfo(Path.Combine(_root.DirectoryName(), path));
                    if (file.IsFile())
                    {
                        Conflicts.Add(path);
                    }
                    else if (file.IsDirectory())
                    {
                        CheckConflictsWithFile(file);
                    }
                }
            }

            Conflicts.RemoveAll(conflict => Removed.Contains(conflict));
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:51,代码来源:WorkDirCheckout.cs

示例4: PushFile

        /// <summary>
        /// Push a single file.
        /// </summary>
        /// <param name="local">the local filepath.</param>
        /// <param name="remote">The remote filepath.</param>
        /// <param name="monitor">The progress monitor. Cannot be null.</param>
        /// <returns>
        /// a SyncResult object with a code and an optional message.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">monitor;Monitor cannot be null</exception>
        /// <exception cref="ArgumentNullException">Throws if monitor is null</exception>
        public SyncResult PushFile( String local, String remote, ISyncProgressMonitor monitor )
        {
            if ( monitor == null ) {
                throw new ArgumentNullException ( "monitor", "Monitor cannot be null" );
            }

            FileInfo f = new FileInfo ( local );
            if ( !f.Exists ) {
                return new SyncResult ( ErrorCodeHelper.RESULT_NO_LOCAL_FILE );
            }

            if ( f.IsDirectory ( ) ) {
                return new SyncResult ( ErrorCodeHelper.RESULT_LOCAL_IS_DIRECTORY );
            }

            monitor.Start ( f.Length );
            SyncResult result = DoPushFile ( local, remote, monitor );
            monitor.Stop ( );

            return result;
        }
开发者ID:otugi,项目名称:SmartArrow-Windows,代码行数:32,代码来源:SyncService.cs

示例5: rename

        private static bool rename(string src, string dst)
        {
            if (new FileInfo(src).RenameTo(dst))
                return true;

            DirectoryInfo dir = new FileInfo(dst).Directory;
            if ((dir.Exists || !dir.Mkdirs()) && !dir.IsDirectory())
                return false;
            return new FileInfo(src).RenameTo(dst);
        }
开发者ID:cocytus,项目名称:Git-Source-Control-Provider,代码行数:10,代码来源:RefDirectoryRename.cs

示例6: SetFile

        void SetFile()
        {
            lock (_thisLock)
            {
                // Check directory
                FileInfo file = new FileInfo(_filename);
                _filename = file.FullName;
                file = new FileInfo(_filename);
                FileInfo dir = new FileInfo(file.Directory.FullName);
                if (!dir.IsDirectory() || !dir.CanWrite())
                    throw new IOException("Cannot write log directory " + dir);

                DateTime now = DateTime.Now;
                if (_timeZoneInfo != null)
                {
                    now = TimeZoneInfo.ConvertTime(now, _timeZoneInfo);
                }

                // Is this a rollover file?
                string filename = file.Name;
                int i = filename.ToLower().IndexOf(YYYY_MM_DD);
                if (i >= 0)
                {
                    file = new FileInfo(Path.Combine(dir.FullName,
                                  filename.Substring(0, i) +
                                  now.ToString(_fileDateFormat) +
                                  filename.Substring(i + YYYY_MM_DD.Length)));
                }

                if (file.Exists && !file.CanWrite())
                    throw new IOException("Cannot write log file " + file);

                // Do we need to change the output stream?
                if (output == null || !file.Equals(_file))
                {
                    // Yep
                    _file = file;
                    if (!_append && file.Exists)
                    {
                        file.MoveTo(new FileInfo(file.ToString() + "." + now.ToString(_fileBackupFormat)).FullName);
                    }
                    Stream oldOut = output;
                    output = new FileStream(
                        file.FullName, _append
                        ? (FileMode.Append | FileMode.CreateNew)
                        : (FileMode.Truncate | FileMode.CreateNew),
                        FileAccess.Write);
                    if (oldOut != null)
                        oldOut.Close();
                    //if(log.isDebugEnabled())log.debug("Opened "+_file);
                }
            }
        }
开发者ID:patricknharris,项目名称:njetty,代码行数:53,代码来源:RolloverFileOutputStream.cs


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