Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#-如何更改名称为空格字符(“空格”)的文件夹的属性?_C#_File_Attributes - Fatal编程技术网

C#-如何更改名称为空格字符(“空格”)的文件夹的属性?

C#-如何更改名称为空格字符(“空格”)的文件夹的属性?,c#,file,attributes,C#,File,Attributes,在C#中,为了更改文件夹的属性,我使用FileAttributes。 例如: -->完成了!化身的属性是正常的 但是,对于名称为“”的文件夹: 我的程序不会抛出任何错误,但该文件夹的属性不会更改。 我能做什么 (某些病毒创建了一个名为“”的隐藏文件夹,并将U盘上的所有数据移动到其中。我想删除该文件夹的隐藏属性) 我的英语语法不好。对不起 尝试将+System.Net.WebUtility.HtmlDecode(@“”)+“\\\”添加到目录名的末尾,而不是空格 您的字符串将如下所示: myf

在C#中,为了更改文件夹的属性,我使用FileAttributes。 例如:

-->完成了!化身的属性是正常的

但是,对于名称为“”的文件夹:

我的程序不会抛出任何错误,但该文件夹的属性不会更改。 我能做什么


(某些病毒创建了一个名为“”的隐藏文件夹,并将U盘上的所有数据移动到其中。我想删除该文件夹的隐藏属性)


我的英语语法不好。对不起

尝试将
+System.Net.WebUtility.HtmlDecode(@“”)+“\\\”
添加到目录名的末尾,而不是空格

您的字符串将如下所示:
myfolder=“C:\\Test Programs\\”+System.Net.WebUtility.HtmlDecode(@“”)+“\\”

完成!。我将
“\\”
添加到我的文件夹中。 使用文件夹Avatar-->
myfolder=“C:\\testprograms\\Avatar\\”

文件夹名为“”-->
myfolder=“C:\\testprograms\\\”

我的程序将该文件夹的属性设置为“正常”


谢谢大家

您在更改之前获得的属性是什么?您是否尝试过
File.SetAttributes(“C:\\Test Programs\\Avatar”,FileAttributes.Normal”)?@RanajitChatterjee:那个文件夹是隐藏的,我想让它出现。@StriterAlfa:我试过了。但我想更改文件夹whích name的属性为“”,而不是文件夹头像^_^试试这个ss.Attributes |=FileAttributes.Normal;
myfolder= "C:\\Test Programs\\Avatar";
DirectoryInfo ss = new DirectoryInfo(myfolder);
ss.Attributes = FileAttributes.Normal;
myfolder= "C:\\Test Programs\\ ";