• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IO.FileSystemInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



FileSystemInfo类属于System.IO命名空间,在下文中一共展示了FileSystemInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MarkdownTreeNode

 public MarkdownTreeNode(FileSystemInfo location, string relativePathFromRoot, XElement markdownContent)
 {
     this.OriginalLocation = location;
     this.OriginalLocationUrl = location.ToUri();
     this.RelativePathFromRoot = relativePathFromRoot;
     this.MarkdownContent = markdownContent;
 }
开发者ID:timblinkbox,项目名称:pickles,代码行数:7,代码来源:MarkdownTreeNode.cs


示例2: ToStringArray

        private static string[] ToStringArray(FileSystemInfo obj,
                                              IEnumerable<object> paths)
        {
            if (null == obj)
            {
                throw new ArgumentNullException("obj");
            }

            var args = new List<string>
                           {
                               obj.FullName
                           };
#if NET20
            if (ObjectExtensionMethods.IsNotNull(paths))
#else
            if (paths.IsNotNull())
#endif
            {
                var range = paths
#if NET20
                    .Where(x => ObjectExtensionMethods.IsNotNull(x))
#else
                    .Where(x => x.IsNotNull())
#endif
                    .Select(path => path.ToString().RemoveIllegalFileCharacters());
                args.AddRange(range);
            }

            return args.ToArray();
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:30,代码来源:FileSystemInfo.ExtensionMethods.cs


示例3: Format

        public static void Format(FtpCommandContext context, FileSystemInfo fileInfo, StringBuilder output)
        {
            var isFile = fileInfo is FileInfo;

            //Size
            output.AppendFormat("size={0};", isFile ? ((FileInfo)fileInfo).Length : 0);

            //Permission
            output.AppendFormat("perm={0}{1};",
                                /* Can read */ isFile ? "r" : "el",
                                /* Can write */ isFile ? "adfw" : "fpcm");
            
            //Type
            output.AppendFormat("type={0};", isFile ? "file" : "dir");

            //Create
            output.AppendFormat("create={0};", FtpDateUtils.FormatFtpDate(fileInfo.CreationTimeUtc));

            //Modify
            output.AppendFormat("modify={0};", FtpDateUtils.FormatFtpDate(fileInfo.LastWriteTimeUtc));

            //File name
            output.Append(DELIM);
            output.Append(fileInfo.Name);

            output.Append(NEWLINE);
        }
开发者ID:Flagwind,项目名称:Zongsoft.CoreLibrary,代码行数:27,代码来源:FtpMlstFileFormater.cs


示例4: ConvertFileSystemInfoToHleIoDirent

        public static unsafe HleIoDirent ConvertFileSystemInfoToHleIoDirent(FileSystemInfo FileSystemInfo)
        {
            var HleIoDirent = default(HleIoDirent);
            var FileInfo = (FileSystemInfo as FileInfo);
            var DirectoryInfo = (FileSystemInfo as DirectoryInfo);
            {
                if (DirectoryInfo != null)
                {
                    HleIoDirent.Stat.Size = 0;
                    HleIoDirent.Stat.Mode = SceMode.Directory | (SceMode)Convert.ToInt32("777", 8);
                    HleIoDirent.Stat.Attributes = IOFileModes.Directory;
                    PointerUtils.StoreStringOnPtr(FileSystemInfo.Name, Encoding.UTF8, HleIoDirent.Name);
                }
                else
                {
                    HleIoDirent.Stat.Size = FileInfo.Length;
                    HleIoDirent.Stat.Mode = SceMode.File | (SceMode)Convert.ToInt32("777", 8);
                    //HleIoDirent.Stat.Attributes = IOFileModes.File | IOFileModes.CanRead | IOFileModes.CanWrite | IOFileModes.CanExecute;
                    HleIoDirent.Stat.Attributes = IOFileModes.File;
                    PointerUtils.StoreStringOnPtr(FileSystemInfo.Name.ToUpper(), Encoding.UTF8, HleIoDirent.Name);
                }

                HleIoDirent.Stat.DeviceDependentData0 = 10;
            }
            return HleIoDirent;
        }
开发者ID:e-COS,项目名称:cspspemu,代码行数:26,代码来源:HleIoDriverLocalFileSystem.cs


示例5: BuildFileBundleName

        /// <summary>
        /// 编译文件AssetBundle名字
        /// </summary>
        /// <param name="file">文件信息</param>
        /// <param name="basePath">基础路径</param>
        protected static void BuildFileBundleName(FileSystemInfo file , string basePath)
        {
            string extension = file.Extension;
            string fullName = file.FullName.Standard();
            string fileName = file.Name;
            string baseFileName = fileName.Substring(0 , fileName.Length - extension.Length);
            string assetName = fullName.Substring(basePath.Length);
            assetName = assetName.Substring(0 , assetName.Length - fileName.Length).TrimEnd('/');

            if(baseFileName + extension == ".DS_Store"){ return; }

            int variantIndex = baseFileName.LastIndexOf(".");
            string variantName = string.Empty;

            if(variantIndex > 0){

                variantName = baseFileName.Substring(variantIndex + 1);

            }

            AssetImporter assetImporter = AssetImporter.GetAtPath("Assets" + Env.ResourcesBuildPath + assetName + "/" + baseFileName + extension);
            assetImporter.assetBundleName = assetName.TrimStart('/');
            if(variantName != string.Empty){

                assetImporter.assetBundleVariant = variantName;

            }
        }
开发者ID:yb199478,项目名称:CatLib,代码行数:33,代码来源:CreateAssetBundles.cs


示例6: CheckOut

        public override string CheckOut(IPackageTree packageTree, FileSystemInfo destination)
        {
            SvnUpdateResult result = null;

            using (var client = new SvnClient())
            {
                try
                {
                    var svnOptions = new SvnCheckOutArgs();
                    if (UseRevision.HasValue)
                        svnOptions.Revision = new SvnRevision(UseRevision.Value);
                    client.CheckOut(new SvnUriTarget(new Uri(Url)), destination.FullName, svnOptions, out result);
                }
                catch (SvnRepositoryIOException sre)
                {
                    HandleExceptions(sre);
                }
                catch (SvnObstructedUpdateException sue)
                {
                    HandleExceptions(sue);
                }
            }

            return result.Revision.ToString();
        }
开发者ID:emmekappa,项目名称:horn_src,代码行数:25,代码来源:SvnSourceControl.cs


示例7: Item

        public Item(FileSystemInfo info)
        {
            Id = Guid.NewGuid().ToString();
            Name = info.Name;
            Created = info.CreationTime;
            Modified = info.LastWriteTime;
            LastAccess = info.LastAccessTime;

            var fileInfo = info as FileInfo;
            if (fileInfo != null)
            {
                m_isReadOnly = fileInfo.IsReadOnly;
                Size = fileInfo.Length;
                IsFile = true;
            }
            else
            {
                IsFile = false;
            }
            FileSecurity fs = File.GetAccessControl(info.FullName);
            var sidOwning = fs.GetOwner(typeof(SecurityIdentifier));
            var ntAccount = sidOwning.Translate(typeof(NTAccount));
            Owner = ntAccount.Value;

            // todo: it's not so important, but still put here something like read, write etc.
            var sidRules = fs.GetAccessRules(true, true, typeof(SecurityIdentifier));
            List<string> rulesList = new List<string>(sidRules.Count);
            for (int i = 0; i < sidRules.Count; i++)
            {
                rulesList.Add(sidRules[i].IdentityReference.Value);
            }
            Rights = string.Join("; ", rulesList);
        }
开发者ID:ILya-Lev,项目名称:FilesPicker,代码行数:33,代码来源:Item.cs


示例8: Create

        public IDirectoryTreeNode Create(FileSystemInfo root, FileSystemInfo location)
        {
            string relativePathFromRoot = root == null ? @".\" : PathExtensions.MakeRelativePath(root, location);

            var directory = location as DirectoryInfo;
            if (directory != null)
            {
                return new FolderDirectoryTreeNode(directory, relativePathFromRoot);
            }

            var file = location as FileInfo;
            if (relevantFileDetector.IsFeatureFile(file))
            {
                Feature feature = featureParser.Parse(file.FullName);
                if (feature != null)
                {
                    return new FeatureDirectoryTreeNode(file, relativePathFromRoot, feature);
                }

                throw new InvalidOperationException("This feature file could not be read and will be excluded");
            }
            else if (relevantFileDetector.IsMarkdownFile(file))
            {
                XElement markdownContent = htmlMarkdownFormatter.Format(File.ReadAllText(file.FullName));
                return new MarkdownTreeNode(file, relativePathFromRoot, markdownContent);
            }

            throw new InvalidOperationException("Cannot create an IItemNode-derived object for " + file.FullName);
        }
开发者ID:ppnrao,项目名称:pickles,代码行数:29,代码来源:FeatureNodeFactory.cs


示例9: CreateItemGetResponse

 protected override Task<HttpResponseMessage> CreateItemGetResponse(FileSystemInfo info, string localFilePath)
 {
     // We don't support getting a file from the zip controller
     // Conceivably, it could be a zip file containing just the one file, but that's rarely interesting
     HttpResponseMessage notFoundResponse = Request.CreateResponse(HttpStatusCode.NotFound);
     return Task.FromResult(notFoundResponse);
 }
开发者ID:BrianVallelunga,项目名称:kudu,代码行数:7,代码来源:ZipController.cs


示例10: Restore

        /// <summary>
        /// This function launch the restore process, with the NpgsqlConnection parameters. Restore
        /// will be done on the server and database pointed by the NpgsqlConnection
        /// </summary>
        /// <param name="connection">The NpgsqlConnection containg the database location
        /// settings</param>
        /// <param name="login">The login used to restore database</param>
        /// <param name="password">The password associed to login</param>
        /// <param name="backupFile">The backup file to restore</param>
        /// <returns>Returns a Result that tells if operation succeeds</returns>
        public Result Restore(
                                IDbConnection connection,
                                string login,
                                string password,
                                FileSystemInfo backupFile)
        {
            IPAddress connectionIpAddress = IPAddress.None;

            if (connection != null)
            {
                // TODO fix connection.Host and connection.Port
                if (IPAddress.TryParse(/*connection.Host*/ "127.0.0.1", out connectionIpAddress)
                    && (connectionIpAddress != IPAddress.None))
                {
                    return this.Restore(
                            connectionIpAddress,
                            5432, // (short)connection.Port,
                            connection.Database,
                            login,
                            password,
                            backupFile);
                }
                else
                {
                    return Result.InvalidIpAddress;
                }
            }

            return Result.InvalidNpgsqlConnection;
        }
开发者ID:gilprime,项目名称:nPgTools,代码行数:40,代码来源:NpgRestore.cs


示例11: DoTouch

    private static void DoTouch(FileSystemInfo fileSystemInfo, DateTime now)
    {
      FileAttributes fileAttributes = fileSystemInfo.Attributes;

      try
      {
        fileSystemInfo.Attributes = FileAttributes.Normal;
        fileSystemInfo.CreationTime = now;
        fileSystemInfo.LastWriteTime = now;
        fileSystemInfo.LastAccessTime = now;
      }
      catch (System.Exception e)
      {
        Console.WriteLine(e.Message);
      }
      finally
      {
        //Restore Attributes in case anything happens
        try
        {
          fileSystemInfo.Attributes = fileAttributes;
        }
        finally
        {
        }
      }
    }
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:27,代码来源:Program.cs


示例12: VideoIsLocatedInAMovieFolder

        internal static bool VideoIsLocatedInAMovieFolder(FileSystemInfo file)
        {
            Application.DoEvents();

            bool isFilm = false;

            foreach (string filmsFolder
                in Settings.FilmsFolders)
            {

                if (String.IsNullOrEmpty
                    (filmsFolder))
                    continue;

                if (!file.FullName
                    .Contains
                    (filmsFolder))
                    continue;

                Debugger.LogMessageToFile(
                    "This video file is contained" +
                    " in the specified films root directory" +
                    " and will be considered to be a film.");

                isFilm = true;

            }

            Application.DoEvents();

            return isFilm;
        }
开发者ID:stavrossk,项目名称:Easy_Film_Importer_for_MeediOS,代码行数:32,代码来源:MediaSectionPopulatorHelpers.cs


示例13: GetFilesToZip

 /// <summary>
 /// Iterate thru all the filesysteminfo objects and add it to our zip file
 /// </summary>
 /// <param name="fileSystemInfosToZip">a collection of files/directores</param>
 /// <param name="z">our existing ZipFile object</param>
 private static void GetFilesToZip(FileSystemInfo[] fileSystemInfosToZip, ZipFile z)
 {
     //check whether the objects are null
     if (fileSystemInfosToZip != null && z != null)
     {
         //iterate thru all the filesystem info objects
         foreach (FileSystemInfo fi in fileSystemInfosToZip)
         {
             //check if it is a directory
             if (fi is DirectoryInfo)
             {
                 DirectoryInfo di = (DirectoryInfo)fi;
                 //add the directory
                 z.AddDirectory(di.FullName);
                 //drill thru the directory to get all
                 //the files and folders inside it.
                 GetFilesToZip(di.GetFileSystemInfos(), z);
             }
             else
             {
                 //add it
                 z.Add(fi.FullName);
             }
         }
     }
 }
开发者ID:dtafe,项目名称:vnr,代码行数:31,代码来源:SharpZipLibExtensions.cs


示例14: Add

 /// <summary>
 /// Add a File/Directory to the ZipFile
 /// </summary>
 /// <param name="z">ZipFile object</param>
 /// <param name="fileSystemInfoToZip">the FileSystemInfo object to zip</param>
 public static void Add(this ZipFile z, FileSystemInfo fileSystemInfoToZip)
 {
     Add(z, new FileSystemInfo[] 
                     { 
                         fileSystemInfoToZip 
                     });
 }
开发者ID:dtafe,项目名称:vnr,代码行数:12,代码来源:SharpZipLibExtensions.cs


示例15: FileGroupInfo

 public FileGroupInfo(FileSystemInfo _main, FileGroupInfoType _type)
 {
     main = _main;
     type = _type;
     files = new List<FileSystemInfo>();
     numbers = new Dictionary<FileSystemInfo, uint>();
 }
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:7,代码来源:FileGroupInfo.cs


示例16: Delete

 /// <summary>
 /// Deletes a file.
 /// </summary>
 /// <param name="file">The file to delete.</param>
 public static void Delete(FileSystemInfo file)
 {
     if (File.Exists(file.FullName))
     {
         File.Delete(file.FullName);
     }
 }
开发者ID:StevenThuriot,项目名称:Saber,代码行数:11,代码来源:DirectoryManager.cs


示例17: Contains

        /// <summary>
        /// Determines if the directory contains the other directory or file at any depth. 
        /// </summary>
        public static bool Contains(this DirectoryInfo dir, FileSystemInfo other)
        {
            if (dir == null) throw new ArgumentNullException("dir");
            if (other == null) throw new ArgumentNullException("other");

            return other.FullName.StartsWith(dir.FullName, true, null);
        }
开发者ID:thomas-parrish,项目名称:Common,代码行数:10,代码来源:FileSystemExtensions.cs


示例18: MakeRelativePath

        public static string MakeRelativePath(FileSystemInfo from, FileSystemInfo to)
        {
            if (from == null) throw new ArgumentNullException("from");
            if (to == null) throw new ArgumentNullException("to");

            return MakeRelativePath(from.FullName, to.FullName);
        }
开发者ID:MikeEast,项目名称:pickles,代码行数:7,代码来源:PathExtensions.cs


示例19: SearchForExistingItemInMoviesSection

        private static bool SearchForExistingItemInMoviesSection(FileSystemInfo file, IEnumerable<string> filmLocations,
             IMLSection section)
        {
            if (filmLocations == null)
                return false;

            // ReSharper disable LoopCanBeConvertedToQuery
            foreach (var movieFolder in Settings.FilmsFolders)
                // ReSharper restore LoopCanBeConvertedToQuery
            {

                if (!file.FullName.Contains(movieFolder))
                    continue;

                //if (filmLocations.Any(location => location == file.FullName))
                //    return true;

                IMLItem item =
                    section.FindItemByExternalID
                        (file.FullName);

                if (item != null)
                    return true;

            }

            return false;
        }
开发者ID:stavrossk,项目名称:Easy_Film_Importer_for_MeediOS,代码行数:28,代码来源:ExistingMediaItemSeachEngine.cs


示例20: SearchInFile

        private static int SearchInFile(FileSystemInfo file, string needle)
        {
            var byteBuffer = File.ReadAllBytes(file.FullName);

            var enc = ReadBOM(byteBuffer);

            if (!Equals(enc, Encoding.ASCII)) // if BOM is detected
            {
                var stringBuffer = enc.GetString(File.ReadAllBytes(file.FullName));
                var offset = stringBuffer.IndexOf(needle, StringComparison.InvariantCulture);

                return offset;
            }

            var encoList = new List<Encoding> // if not - search by all ways
            {
                Encoding.Default,
                Encoding.ASCII,
                Encoding.UTF8,
                Encoding.Unicode,
                Encoding.BigEndianUnicode
            };

            foreach (var enco in encoList)
            {
                var offset = enco.GetString(byteBuffer).IndexOf(needle, StringComparison.InvariantCulture);
                if (offset == -1) continue;
                return offset;
            }
            return -1;
        }
开发者ID:kekal,项目名称:TextSearch,代码行数:31,代码来源:Program.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IO.FileSystemWatcher类代码示例发布时间:2022-05-26
下一篇:
C# IO.FileSystemEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap