开发者

Problem with DesignerSerializationVisibility attribute [Winform]

开发者 https://www.devze.com 2023-02-24 07:54 出处:网络
I have a problem with a property which has a [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] attribute :

I have a problem with a property which has a [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] attribute :

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public String FileName
    {
        get
        {
            return this._fileName;
        }

        set
     开发者_JAVA百科   {
            File.Move(this._fileName, value);
            this._fileName = value;
        }
    }

If I comment the File.Move method, all is fine but I want to my fileName is renamed if the property FileName has changed in the properties window.

Why DesignerSerializationVisibility attribute don't accept a method in a setter ? Is there any way to solve this problem ?

Thank you !


You should probably enclose that File.Move statement in a Try...Catch block.

Of course, having a File.Move action in a property is probably not the best place to put code like that, especially since the Designer is firing that method every time it opens.

0

精彩评论

暂无评论...
验证码 换一张
取 消