Why is access to the path denied?

前端 未结 29 1548
刺人心
刺人心 2020-11-22 15:25

I am having a problem where I am trying to delete my file but I get an exception.

if (result == \"Success\")
{
     if (FileUpload.HasFile)
     {
         t         


        
29条回答
  •  旧巷少年郎
    2020-11-22 15:41

    I have found that this error can occur in DESIGN MODE as opposed to ? execution mode... If you are doing something such as creating a class member which requires access to an .INI or .HTM file (configuration file, help file) you might want to NOT initialize the item in the declaration, but initialize it later in FORM_Load() etc... When you DO initialize... Use a guard IF statement:

        /// FORM: BasicApp - Load
        private void BasicApp_Load(object sender, EventArgs e)
        {
            // Setup Main Form Caption with App Name and Config Control Info
            if (!DesignMode)
            {
                m_Globals = new Globals();
                Text = TGG.GetApplicationConfigInfo();
            }
        }
    

    This will keep the MSVS Designer from trying to create an INI or HTM file when you are in design mode.

提交回复
热议问题