FileDialogue.Choose() does not work

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

Hello!

I created an empty configuration and for command "import" I just took the code from another old application, and it does not work:

Code
Mode = FileDialogMode.Open;
   OpeningFileDialogue = New FileDialog(Mode);
   OpeningFileDialogue.FullFileName = "";
   Filter = "Excel(*.xlsx)|*.xlsx|Excel 97(*.xls)|*.xls";
   OpeningFileDialogue.Filter = Filter;
   OpeningFileDialogue.Multiselect = False;
   OpeningFileDialogue.Title = "Select file";
   If OpeningFileDialogue.Choose() Then
       FilesArray = OpeningFileDialogue.SelectedFiles;
       For Each FileName In FilesArray Do
           Selection = New File(FileName);
           //Message(FileName+"; Size = "+Selection.Size());
      EndDo;
      ImportAtServer(Selection.FullName);
      //UpdatePriceList();
   Else
       DoMessageBox("File(s) not selected!");
   EndIf;   
EndProcedure


In the line OpeningFileDialogue.Choose() I get an error:

{Catalog.CustomersSite.Form.ListForm.Form(16)}: Error calling context method (Choose)
If OpeningFileDialogue.Choose() Then
because:
Cannot call synchronous methods on the client!

What's wrong?

Thank you for every advice!

 
#2
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

Well, I figured it out! I needed to change properties of the configuration

Now it works!

 
#3
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Lioudmila!

If you are going to use Web client, you will need to disable modality usage and synchronous calls and use asynchronous functions.
In this case, you need to use the FileDialogMode.Show() method.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.