Get a list of files on a server using ASP.NET using a picker

Is there a list of available FileUpload files that shows files on the server, and not on the client?

I am mainly looking for a clean dialog box for selecting server-side files, such as the file used in FileUpload.

+3
source share
2 answers

Nope. No. However, you can use the list and upload files to it.

public sub file_DatabindListbox(directoryPath as string)
   for each fName as string in io.directory(directorypath).getfilenames()
     dim li as new listitem 
     li.text = io.path.getfilename(fName)
     li.value = fName
     myFileListbox.Items.Add(li)
   next
end sub 
+1
source

, FileUpload, ... , " ", , , . , , TreeView - :

protected void Page_Load(object sender, EventArgs e)
{
        SetChildFolders(trvFiles.Nodes, @"C:\MyFolder");
}

    private void SetChildFolders(TreeNodeCollection nodes, string path)
    {
        foreach (string directory in Directory.GetDirectories(path))
        {
            DirectoryInfo dirInfo = new DirectoryInfo(directory);
            TreeNode node = new TreeNode(dirInfo.Name, dirInfo.FullName);

            SetChildFolders(node.ChildNodes, dirInfo.FullName);
            SetChildFiles(node.ChildNodes, dirInfo.FullName);

            trvFiles.Nodes.Add(node);
        }
    }

    private void SetChildFiles(TreeNodeCollection nodes, string path)
    {
        foreach (string file in Directory.GetFiles(path))
        {
            FileInfo fileInfo = new FileInfo(file);
            nodes.Add(new TreeNode(fileInfo.Name, fileInfo.FullName));
        }
    }

, , .

0

Source: https://habr.com/ru/post/1697671/


All Articles