系统文件Hosts在打开编辑后 保存的时候出错  网上找了点资料 好像关于hosts文件属性 求教 怎么保存hosts文件

解决方案 »

  1.   

    void HostConfig::OnSave() 
    {
    // TODO: Add your control notification handler code here
    UpdateData(true);
    // SetFileAttributes(str_path,);设置文件属性
    CStdioFile file; 
    file.Open(str_path,CFile::modeCreate | CFile::modeWrite);
    file.WriteString(m_edit);   
    file.Close(); 
      

  2.   

    系统文件当然要受到更多一点的保护,你把该文件的属性中的系统、隐藏、只读去掉就可以了,
    如果还不行,就是你用来编辑hosts的编辑器的运行权限不够,右击记事本的快捷键,选择用管理员打开,再打开hosts文件,修改后再保存