由于经常在不同的工作地点和家里工作,电脑的ip经常需要重新设置;
因此自制了一个ip地址设置器,方便在不同办公环境下的ip地址切换。用xml存储每个办公场所的ip、dns设置,于是winform的bin\debug下有了:
WindowsFormsApplication1.exe
setting.xml
这两个文件,期望能够把这两个文件合成一个exe文件,无需安装...

解决方案 »

  1.   

    不明白lz想干啥,lz这个就是绿色软件
      

  2.   

    是,我不要做成可安装的程序,那就是绿色的了。
    问题是我要把这两个文件一起复制给同事或网友去使用这个软件,显然是不好的体验;
    我希望把exe文件和xml文件合成一个exe文件,这样使用起来方便!
      

  3.   

    你可以将xml作为内嵌资源,不过修改不了。
      

  4.   

    一个 cmd/bat脚本可搞定了
    >netsh interface ip set address
    One or more essential parameters were not entered.
    Verify the required parameters, and reenter them.
    The syntax supplied for this command is not valid. Check help for the correct syntax.Usage: set address [name=]<string>
                 [[source=]dhcp|static]
                 [[address=]<IPv4 address>[/<integer>] [[mask=]<IPv4 mask>]
                 [[gateway=]<IPv4 address>|none [gwmetric=]<integer>]
                 [[type=]unicast|anycast]
                 [[subinterface=]<string>]
                 [[store=]active|persistent]Parameters:       Tag            Value
           name         - Interface name or index.
           source       - One of the following values:
                          dhcp: Enables DHCP for configuring IP addresses for
                                the specified interface.
                          static: Disables DHCP for configuring IP addresses for
                                the specified interface. This value must be
                                specified if an address or a gateway is being
                                configured.
           address      - IPv4 address to add or modify, optionally followed by
                          the subnet prefix length.
           mask         - The IP subnet mask for the specified IP address.
           gateway      - One of the following values:
                          <IPv4 address>: A specific default gateway for the
                                          static IP address you are setting.
                          none: No default gateways are set.  This is the default.
           gwmetric     - The metric for the default gateway. This field should
                          be set only if gateway is specified.
           type         - One of the following values:
                          unicast: Marks the address as a unicast address.
                                   This is the default.
                          anycast: Marks the address as an anycast address.
           subinterface - LUID of the subinterface on which the default gateway
                          exists.  This parameter is only needed on interfaces
                          with multiple subinterfaces.
           store        - One of the following values:
                          active: Set only lasts until next boot.
                          persistent: Set is persistent.  This is the default.Res: Used to enable or disable DHCP for IP address configuration.
             Also removes any previous static IP addresses and default gateways,
             and can add a new static IP address and default gateway.Examples:       set address name="Local Area Connection" source=dhcp
           set address "Local Area connection" static 10.0.0.9 255.0.0.0 10.0.0.1 1
      

  5.   

    这个好办,你可以把setting里的内容写进exe中的资源,每次新加内容也都写进资源即可
      

  6.   

    我在windows7下改ip都做不到,只能xp,你能做到已经很牛了,至于要做成一个exe,思路这样,程序方件后面是可以追加数据的,但程序打开的时候没权限改自身,所以你得把自身复制一份,打开的时候运行复制的那份,自身的文件当数据用
      

  7.   

    你不用在xml写死IP和dns啊
    直接在程序里每次启动的时候自动获取本机的IP和dns
    这样不是就可以了吗?
    你换个工作地方,程序 启动的时候会自动获取本机IP和dns
    IPAddress[] addrIP = Dns.GetHostAddresses(Dns.GetHostName());//获取可以使用的本机ip
                //localAddress = addrIP[0];
                foreach (var ip in addrIP)
                {
                    //判断是否为IPv4地址
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        localAddress = ip;
                        break;
                    }
                }
      

  8.   

     为何要写死的一说
     加个自定配置 IP 和DNS 不就行了  
      

  9.   

    将XML内嵌的exe中,程序运行时检测是否有XML配置文件,没有就释放内嵌的XML。
      

  10.   

    解决方案里  鼠标右键 setting.xml 属性  生成操作 Resource  编译后 就合并到exe里去了