在asp.net WebApplication中使用FolderBrowserDialog

时间:2013-11-16 07:07:31

标签: c# asp.net

我正在开发asp.net Web应用程序。我想选择文件夹并上传所选文件夹中的所有文件。为此我已经使用FolderBrowserDialog控件。这是我的代码

FolderBrowserDialog fi = new FolderBrowserDialog();

DialogResult result = fi.ShowDialog();

if (result == DialogResult.OK)
{
    string foldername = fi.SelectedPath;
    foreach (string filename in Directory.GetFiles(foldername))
    {
        string asfas = filename;
    }
}

但它提供错误Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

1 个答案:

答案 0 :(得分:0)

我想你应该添加MessageBoxOptions.ServiceNotification

MessageBox.Show(message, "test", System.Windows.Forms.MessageBoxButtons.YesNo, 
   System.Windows.Forms.MessageBoxIcon.Error,     
   System.Windows.Forms.MessageBoxDefaultButton.Button1, 
   System.Windows.Forms.MessageBoxOptions.ServiceNotification);