public IEnumerable<IListFileItem> GetFilesInDirectory()
{
var directory = GetFileShareDirectory();
IEnumerable<IListFileItem> allFilesInDirectory = directory.ListFilesAndDirectories();
List<IListFileItem> allFiles = new List<IListFileItem>();
foreach (var file in allFilesInDirectory)
{
string[] fileType = file.GetType().ToString().Split('.');
string type = fileType[fileType.Length - 1];
if (type == "CloudFile")
{
allFiles.Add(file);
}
}
return allFiles;
}
This code returns all the files in the directory on fileshare on azure, is there any way I can change this to an array? The method I am trying to us wants an array. Please advice, Thank you
is there any way I can change this to an array?
If you want to get an array when call this method, you also need to change the return type to IListFileItem[] in addition to add ToArray method.
public IListFileItem[] GetFilesInDirectory()
{
var directory = GetFileShareDirectory();
IEnumerable<IListFileItem> allFilesInDirectory = directory.ListFilesAndDirectories();
List<IListFileItem> allFiles = new List<IListFileItem>();
foreach (var file in allFilesInDirectory)
{
string[] fileType = file.GetType().ToString().Split('.');
string type = fileType[fileType.Length - 1];
if (type == "CloudFile")
{
allFiles.Add(file);
}
}
return allFiles.ToArray();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.