Пример #1
0
        /// <summary>
        /// Event Handler for OK button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ok_Click(object sender, System.EventArgs e)
        {
            successful = true;

            if (GetDriveType(Path.GetPathRoot(iFolderLocation.Text)) == DRIVE_FIXED)
            {
                if (!Directory.Exists(iFolderLocation.Text))
                {
                    // If a leaf node is specified, the directory will be created
                    // under the current working directory ... display this path.
                    bool   parentExists = false;
                    string parent       = Path.GetDirectoryName(iFolderLocation.Text);
                    while ((parent != null) && !parent.Equals(string.Empty))
                    {
                        if (Directory.Exists(parent))
                        {
                            iFolderLocation.Text = iFolderLocation.Text.Replace(parent, CreateiFolder.FixPath(parent));
                            parentExists         = true;
                            break;
                        }

                        parent = Path.GetDirectoryName(parent);
                    }

                    if (!parentExists)
                    {
                        iFolderLocation.Text = Path.Combine(Environment.CurrentDirectory, iFolderLocation.Text);
                    }

                    // The directory doesn't exist ...
                    if (MessageBox.Show(resourceManager.GetString("createDirectoryMessage"), resourceManager.GetString("createDirectoryTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        // Create the directory.
                        try
                        {
                            Directory.CreateDirectory(iFolderLocation.Text);
                        }
                        catch (Exception ex)
                        {
                            MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("createDirectoryError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                            mmb.ShowDialog();
                            iFolderLocation.Focus();
                            successful = false;
                        }
                    }
                    else
                    {
                        iFolderLocation.Focus();
                        successful = false;
                    }
                }

                if (successful)
                {
                    // Check to make sure the user has rights to this directory.
                    if (Win32Security.AccessAllowed(iFolderLocation.Text))
                    {
                        try
                        {
                            // Display wait cursor.
                            Cursor = Cursors.WaitCursor;

                            // Accept the invitation.
                            ifWebService.AcceptiFolderInvitation(ifolder.DomainID, ifolder.ID, iFolderLocation.Text);
                            Cursor = Cursors.Default;
                        }
                        catch (Exception ex)
                        {
                            Cursor = Cursors.Default;
                            MyMessageBox mmb;

                            if (ex.Message.IndexOf("PathExists") != -1)
                            {
                                mmb = new MyMessageBox(resourceManager.GetString("pathExistsError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                                mmb.ShowDialog();
                                iFolderLocation.Focus();
                            }
                            else if (ex.Message.IndexOf("AtOrInsideStorePath") != -1)
                            {
                                mmb = new MyMessageBox(resourceManager.GetString("pathInStoreError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                                mmb.ShowDialog();
                                iFolderLocation.Focus();
                            }
                            else if (ex.Message.IndexOf("AtOrInsideCollectionPath") != -1)
                            {
                                mmb = new MyMessageBox(resourceManager.GetString("pathIniFolderError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                                mmb.ShowDialog();
                                iFolderLocation.Focus();
                            }
                            else if (ex.Message.IndexOf("IncludesWinDirPath") != -1)
                            {
                                mmb = new MyMessageBox(resourceManager.GetString("pathIncludesWinDirError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                                mmb.ShowDialog();
                                iFolderLocation.Focus();
                            }
                            else if (ex.Message.IndexOf("IncludesProgFilesPath") != -1)
                            {
                                mmb = new MyMessageBox(resourceManager.GetString("pathIncludesProgFilesDirError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                                mmb.ShowDialog();
                                iFolderLocation.Focus();
                            }
                            else
                            {
                                mmb = new MyMessageBox(resourceManager.GetString("acceptError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                                mmb.ShowDialog();
                            }

                            successful = false;
                        }
                    }
                    else
                    {
                        successful = false;
                        MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("accessDenied"), string.Empty, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                        mmb.ShowDialog();
                    }
                }
            }
            else
            {
                MessageBox.Show(resourceManager.GetString("networkPath"), resourceManager.GetString("pathInvalidErrorTitle"));
                iFolderLocation.Focus();
                successful = false;
            }
        }