下面这段代码一执行到红字部分,就说filePath这个路径正在被使用,不能引用,请问是什么问题应该怎么解决?
if (this.fileMode == "new")
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.DefaultExt = ".txt";
                
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    if (sfd.FileName != "")
                    {
                        if (File.Exists(sfd.FileName))
                        {
                            if (MessageBox.Show(this, "This Filename has exist,do you want to continue?", "Same Name", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                            {
                                File.Create(sfd.FileName);
                                filePath = sfd.FileName;
                            }
                            else { return; }
                        }
                        else
                        {
                            File.Create(sfd.FileName);
                            filePath = sfd.FileName;
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "Please input filename!", "new file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
            }
            try
            {
                StreamWriter sw = new StreamWriter(filePath);                if (sw != null)
                {
                    sw.Write(this.textBox1.Text);
                }
                sw.Close();
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }            this.Close();