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


C# System.IO.DirectoryInfo.GetFileSystemInfos方法代码示例

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


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

示例1: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            var request = context.Request;
            string path = request.Params["path"];

            if (string.IsNullOrEmpty(path))
                path = @"D:\Stefan.Steiger\Source\Repos";

            // System.IO.Directory.GetFileSystemEntries(path);
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
            System.IO.FileSystemInfo[] fis = di.GetFileSystemInfos();

            List<fsInfo> ls = new List<fsInfo>();

            foreach (System.IO.FileSystemInfo fi in fis)
            {
                ls.Add(new fsInfo(fi));
                Console.WriteLine(fi);

            }

            // string resp = Newtonsoft.Json.JsonConvert.SerializeObject(ls);
            string resp = resp = MyGit.JsonHelper.SerializePretty(ls);

            context.Response.ContentType = "application/JSON";
            context.Response.Write(resp);
        }
开发者ID:moacap,项目名称:MongoUpload,代码行数:27,代码来源:RepoContent.ashx.cs

示例2: ExtractImageFiles

 /* ----------------------------------------------------------------- */
 ///
 /// ExtractImageFiles
 /// 
 /// <summary>
 /// 指定されたパスから対象となる画像ファイルのパスを抽出する.
 /// src がフォルダの場合は,再帰的に展開する.
 /// </summary>
 /// 
 /* ----------------------------------------------------------------- */
 private void ExtractImageFiles(string src, Container.List<string> dest)
 {
     if (System.IO.Directory.Exists(src)) {
         var dir = new System.IO.DirectoryInfo(src);
         foreach (var item in dir.GetFileSystemInfos()) {
             this.ExtractImageFiles(item.FullName, dest);
         }
     }
     else {
         var ext = System.IO.Path.GetExtension(src).ToLower();
         if (ext == ".bmp" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif") dest.Add(src);
     }
 }
开发者ID:clown,项目名称:Image2WebP,代码行数:23,代码来源:MainForm.cs

示例3: DoRestore

        static void DoRestore(string backupDir, string targetDrive)
        {
            System.IO.DirectoryInfo dirInfo;

            List<System.IO.FileInfo> fileInfos = new List<System.IO.FileInfo>();

            string backupDirFull = System.IO.Path.GetFullPath(backupDir);

            // Recursively get a list of FileInfos for the backed up files
            try
            {
                dirInfo = new System.IO.DirectoryInfo(backupDirFull);
                if (!dirInfo.Exists)
                {
                    throw new System.IO.DirectoryNotFoundException();
                }

                GetFileSystemInfosRecurse(dirInfo.GetFileSystemInfos(), fileInfos);
            }
            catch (System.IO.IOException)
            {
                Console.WriteLine("ERROR: Failed to list files in backup directory.");
                return;
            }

            if(fileInfos.Count == 0)
            {
                Console.WriteLine("ERROR: No files in backup directory to restore.");
                return;
            }

            string filesForEdit = "";
            string filesForAdd = "";

            System.IO.FileInfo deletedFileInfo = null;
            System.IO.FileInfo descFileInfo = null;

            // Find any existing files that need to be opened for edit, the rest are for add.
            foreach (System.IO.FileInfo fileInfo in fileInfos)
            {
                if(fileInfo.Name == k_DeletesFilename)
                {
                    deletedFileInfo = fileInfo;
                }
                else if (fileInfo.Name == k_DescFilename)
                {
                    descFileInfo = fileInfo;
                }
                else
                {
                    string localFilename = targetDrive + fileInfo.FullName.Substring(backupDirFull.Length);

                    if (System.IO.File.Exists(localFilename))
                    {
                        filesForEdit += localFilename + " ";
                    }
                    else
                    {
                        filesForAdd += localFilename + " ";
                    }
                }
            }

            string desc = "P4Backup restored files";

            // Remove __description.txt from the list of fileinfos, since it's not a real p4 file to be restored
            if (descFileInfo != null)
            {
                fileInfos.Remove(descFileInfo);

                try
                {
                    System.IO.StreamReader SR = descFileInfo.OpenText();
                    desc = SR.ReadToEnd();
                }
                catch (System.IO.IOException e)
                {
                    Console.WriteLine("ERROR: Failed to open \"__description.txt\". Aborting.  Error: " + e.Message);
                    return;
                }
            }

            // Make the new changelist to hold the restored files in P4.
            int changeListID = -1;

            if (!P4Shell.CreateChangelist(desc, ref changeListID))
            {
                Console.WriteLine("ERROR: Failed to create new changelist.");
                Console.WriteLine(P4Shell.Error);
                return;
            }

            // Remove __deletes.txt from the the list of fileinfos, since it's not a real p4 file to be restored
            if(deletedFileInfo != null)
            {
                fileInfos.Remove(deletedFileInfo);

                StringBuilder deletedFilenamesMerged = new StringBuilder();

                Console.WriteLine("Processing deletes from __deletes.txt...");
//.........这里部分代码省略.........
开发者ID:jurney,项目名称:P4Backup,代码行数:101,代码来源:Program.cs

示例4: GetChildNamesPrivate

 private List<string> GetChildNamesPrivate(string path)
 {
     path = path == "" ? "." : path; // Workaround until our globber handles relative paths
     path = NormalizePath(path);
     System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(path);
     if (!directory.Exists)
     {
         return new List<string> { new System.IO.FileInfo(path).Name };
     }
     return (from fs in directory.GetFileSystemInfos() select fs.Name).ToList();
 }
开发者ID:mauve,项目名称:Pash,代码行数:11,代码来源:FileSystemProvider.cs

示例5: Main


//.........这里部分代码省略.........
                        now = System.DateTime.Now;
                        fiL = di.GetFiles ();
                    } catch (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.GetFiles()");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + toString (fiL));
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                    }
                    try {
                        exc = null;
                        diL = null;
                        now = System.DateTime.Now;
                        diL = di.GetDirectories ();
                    } catch (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.GetDirectories()");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + toString (diL));
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                    }
                    try {
                        exc = null;
                        fsiL = null;
                        now = System.DateTime.Now;
                        fsiL = di.GetFileSystemInfos ();
                    } catch (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.GetFileSystemInfos()");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + toString (fsiL));
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                    }
                    try {
                        exc = null;
                        now = System.DateTime.Now;
                        di.MoveTo (tempPath + "\\TestDir4");
                    } catch (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.MoveTo(String)");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + "");
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                        //---
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir4");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.MoveTo(String)");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + "");
                        outFile.WriteLine ("Errc: " + "");
开发者ID:uvbs,项目名称:Holodeck,代码行数:67,代码来源:TestApplication4.cs


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