用操作系统生成desktop.ini文件 ,怎么都没问题,但我用程序创建却就是不行,ini文件属性设置了只读、隐藏、系统,包括设置目录也做了系统、只读等各种属性设置测试,但就是没反应,晕死,哪位达人弄过,提示一下。

解决方案 »

  1.   

     FileStream fs = new FileStream(Path + "\\desktop.ini", FileMode.Append);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(@"[.ShellClassInfo] (“.”为一个半角的英文句点) ");
                sw.WriteLine(@"InfoTip=专用文件夹,请勿修改。");
                sw.WriteLine(@"InfoTip=IconFile=C:\测试\Program.EXE");
                sw.WriteLine(@"IconIndex=0");
                sw.Close();
                fs.Close();
                sw.Dispose();
                fs.Dispose();
                FileInfo fi = new FileInfo(Path + "\\desktop.ini");
                fi.IsReadOnly = true;            fi.Attributes = fi.Attributes | FileAttributes.System | FileAttributes.Hidden | FileAttributes.ReadOnly;
      

  2.   

    参考:
    http://school.itzcn.com/special-spid-12.html
    上面有关于这方面的信息,楼主可以看看,希望对你有所帮助。
      

  3.   

    [.ShellClassInfo]
    IconFile=%SystemRoot%\system32\SHELL32.dll
    IconIndex=4
      

  4.   

    attrib [文件名] +s +h
    这样就能 隐藏
      

  5.   

    lz 写标题跟内容不一样哦不过我还是喜欢答标题的那个问题:用shell扩展
      

  6.   

    以下代码是我的文档里面,我的视频 文件夹的 desktop.ini文件的内容 
    [.ShellClassInfo]
    [email protected],-12690
    IconFile=%SystemRoot%\system32\SHELL32.dll
    IconIndex=-238
    [DeleteOnCopy]
    Owner=Administrator
    Personalized=14
    PersonalizedName=My Videos
      

  7.   

    不对吧,我安装了迅雷,然后设定了一个默认下载目录
    然后迅雷就改变了我的文件夹的图片,他的desktop.ini文件是这样的[.ShellClassInfo]
    ConfirmFileOp=0
    NoSharing=1
    IconFile=C:\Program Files\Thunder Network\Thunder\Program\downloadfolder.ico
    IconIndex=0
    InfoTip=迅雷下载文件夹虽然已经结贴了,希望对你有帮助