protected ListGetFilesInFolder(string folderVirtualPath)
{
string physicalPathToFolder = Server.MapPath(folderVirtualPath);// Get the physical path
string filterExpression = "*.gif";
string[] physicalPathsCollection = System.IO.Directory.GetFiles(physicalPathToFolder,
filterExpression);// Get all child files of the given folder
ListvirtualPathsCollection = new List ();// Contains the result
foreach (String path in physicalPathsCollection)
{
// The value of virtualPath will be similar to '~/PathToFolder/Image1.jpg
string virtualPath = VirtualPathUtility.AppendTrailingSlash(folderVirtualPath) +
System.IO.Path.GetFileName(path);
virtualPathsCollection.Add(virtualPath);
}
return virtualPathsCollection;
}
I do my thing and you do yours. I am not in this world to live up to your expectations, and you are not in this world to live up to mine. You are you and I am I, and if by chance we find each other, then it is beautiful. If not, it can't be helped.
Wednesday, August 10, 2011
C# Get ALL Image File In a Folder
Labels:
C#
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment