简体   繁体   中英

Folder Explorer

I´m developing an intranet where I need to select a server side folder to store some data. It has to be on the server side, so I need a to create partial view where a user can navigate through server folder structure (commonly network mapper drive) and choose a folder.

I have this now:

List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));

List<string> files = new List<string>();
DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
foreach (string fInfo in Directory
                         .EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly)
                         .Where(s => s.EndsWith(".png")
                                || s.EndsWith(".PNG")
                                || s.EndsWith(".jpg")
                                || s.EndsWith(".JPG")
                         ).Select(Path.GetFileName))
{
    files.Add(fInfo);
}

But did someone know a jQuery library or something to make a user select a server side folder?

Thanks in advance

You can simplify this loop using the MimeMapping object

MimeMapping.GetMimeMapping("file.png"); // => "image/png"

So your loop can loop over and grab all the files that meet particular mime types (image/ , text/ , etc...)

Consider using a restful ajax approach to uploading data to the server

POST /client_data/image.png

binary image data

your server logic could then parse out the image and store it locally

https://msdn.microsoft.com/en-us/library/system.web.mimemapping.getmimemapping(v=vs.110).aspx

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM