Assets.FileSystem.ListFilesInDirectory C# (CSharp) Method

ListFilesInDirectory() public static method

public static ListFilesInDirectory ( string path ) : List
path string
return List
        public static List<string> ListFilesInDirectory(string path)
        {
            List<string> result = new List<string>();
            DirectoryInfo apple = new DirectoryInfo(@path);
            foreach (FileInfo file in apple.GetFiles("*"))
                result.Add(file.Name);

            return result;
        }

Usage Example

Example #1
0
        public void Clear()
        {
            List <string> fileNameVec = FileSystem.ListFilesInDirectory(Globals.IpcPath);

            foreach (string fileNameCurrent in fileNameVec)
            {
                string fileNameEveryone = "";
                if (fileNameCurrent.Length >= 8)
                {
                    fileNameEveryone = fileNameCurrent.Substring(0, 8);
                }

                if (fileNameCurrent.Length > selfName.Length || fileNameEveryone == "everyone")
                {
                    string fileName   = "";
                    string fileNameID = "";
                    if (fileNameEveryone != "everyone")
                    {
                        fileName   = fileNameCurrent.Substring(0, selfName.Length);
                        fileNameID = fileNameCurrent.Substring(selfName.Length, fileNameCurrent.Length - selfName.Length);
                    }
                    else
                    {
                        continue;
                    }

                    if (fileName == selfName || fileNameEveryone == "everyone")
                    {
                        FileSystem.DeleteFile(Globals.IpcPath + "\\" + fileNameCurrent);
                    }
                }
            }
        }
All Usage Examples Of Assets.FileSystem::ListFilesInDirectory