制作C#ta文件夹保护文件 [英] Making C # ta folder protected file

查看:57
本文介绍了制作C#ta文件夹保护文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want my C # ta folder to be protected and hidden, how can I do i





我尝试过:





What I have tried:

string yol = @"E:\Yeni klasör";

            DirectoryInfo[] klasorler = di.GetDirectories();

            foreach (DirectoryInfo klasor in klasorler)
            {
                //{

                if (klasor.Name == "Yeni Klasör")
                {
                    if ((klasor.Attributes & FileAttributes.Normal) == 0)
                    {
                        File.SetAttributes(yol, FileAttributes.System);

                        File.SetAttributes(yol, FileAttributes.Hidden);
                        


                    }
                }

推荐答案

嗯...也许你的意思是:

Well...perhaps you meant this:
if ((klasor.Attributes & FileAttributes.Normal) == 0)
    {
    File.SetAttributes(klasor.FullName, FileAttributes.System);
    File.SetAttributes(klasor.FullName, FileAttributes.Hidden);
    }

目前你(大概)每次循环都设置父文件夹的属性。

At the moment you are (presumably) setting the attributes for the parent folder each time round the loop.


这篇关于制作C#ta文件夹保护文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆