Ticket T264172
Visible to All Users

ASPxFileManager - How to set the SelectedFile property by creating the FileManagerFile object

created 10 years ago

Hello,
I can't select file in ASPxFileManager. How can i set fs and relpath?

C#
ASPxFileRepositoryManager.SelectedFile = new DevExpress.Web.FileManagerFile(fs,relpath);

Can you send me some functional example?

Thanks.

Marek

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hi,

Here is a small code example:

C#
ASPxFileManager1.SelectedFile = ASPxFileManager1.SelectedFolder.GetFiles().First();

Updated by Pavlo
The constructor of FileManagerFile(FileSystemProviderBase,String) has two arguments:
1. FileSystemProviderBase provider - the file system provider that is used to get files. You can get the current provider object from the ASPxFileManager.CustomFileSystemProvider property.
2. String relativeName - a relative path to the file. For example, "Files/file.txt" or "file.txt" (if the file is in the root folder).

To select the file, create a new FileManagerFile object by specifying the mentioned parameters:

C#
ASPxFileManager1.SelectedFile = new FileManagerFile(ASPxFileManager1.CustomFileSystemProvider, "Folder2/text.txt");

Note that the file will be selected on the client side (visually) only if it is in the current File Container. I.e., the file manager will not open the folder where the selected file is located.

I created a sample project to illustrate this approach.

Thanks,
Alessandro.

    Show previous comments (1)
    DevExpress Support Team 10 years ago

      Hello,

      The constructor of FileManagerFile(FileSystemProviderBase,String) has two arguments:
      1. FileSystemProviderBase provider - the file system provider that is used to get files. You can get the current provider object from the ASPxFileManager.CustomFileSystemProvider property.
      2. String relativeName - a relative path to the file. For example, "Files/file.txt" or "file.txt" (if the file is in the root folder).

      To select the file, create a new FileManagerFile object by specifying the mentioned parameters:

      C#
      ASPxFileManager1.SelectedFile = new FileManagerFile(ASPxFileManager1.CustomFileSystemProvider, "Folder2/text.txt");

      Note that the file will be selected on the client side (visually) only if it is in the current File Container. I.e., the file manager will not open the folder where the selected file is located.

      I created a sample project to illustrate this approach.

      Best regards,
      Pavlo

      CT CT
      ClickHelp Team 9 years ago

        I'm trying to accomplish the same task in 15.1.6, but fail to do so. I have a custom provider as well and your sample works fine for me, but in my real app I need to select a file when the page is initially loaded. So, I tried both ASPxFileManager1.SelectedFile = ASPxFileManager1.SelectedFolder.GetFiles()[0] and the suggested ASPxFileManager1.SelectedFile = new FileManagerFile(ASPxFileManager1.CustomFileSystemProvider, "Folder2/text.txt"), but neither worked for me.
        Then, I created a very basic sample with the standard provider and just one line of code, but it did not work for me either. I feel that I'm missing something obvious here… I've attached the sample to this post - please make it select a file (any file) when the page is initially loaded.
        I'm using a hotfix (15.1.6.15245), if that matters.
        Nickolay, Software Architect
        ClickHelp - Online Documentation Tool
        http://clickhelp.co

        DevExpress Support Team 9 years ago

          Hello,

          To process your recent post more efficiently, I created a separate ticket on your behalf: T291164: ASPxFileManager - File is not selected when selecting it on server side on first page load. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.