Hack Forums
[.NET] How to set folder arrtibute to hidden using vb.net - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] How to set folder arrtibute to hidden using vb.net (/showthread.php?tid=5320804)



How to set folder arrtibute to hidden using vb.net - -Various - Jun 28, 2016

I'm trying to set fodler arrtibute to hidden using vb.net



Code
IO.File.SetAttributes("%appdata%", & ("\test")"
IO.FileAttributes.Hidden)

but its not working..
thanks in advance i'm new to this.


* - Neos07 - Jun 28, 2016

Try this:
Code
IO.File.SetAttributes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\test", IO.FileAttributes.Hidden)
And make sure you have the folder "test" in AppData\Roaming.


* - He B TeMy - Jun 28, 2016

Post above code will only apply the attribute to the folder, if you want to hide the folder's content (either other folders or files) you'll have to do it for each file/folder.


* - -Various - Jun 28, 2016

(Jun 28, 2016 10:40 AM)Neos07 Wrote:  Try this:
Code
IO.File.SetAttributes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\test", IO.FileAttributes.Hidden)
And make sure you have the folder "test" in AppData\Roaming.
I get this error
[Image: 5251a455bd.png]


* - Odus - Jun 28, 2016

(Jun 28, 2016 10:48 AM)-Various Wrote:  I get this error
[Image: 5251a455bd.png]

Not his fault you can't even use your clipboard correctly.

[Image: 3d835fd37e9542e86029ea75f7de2965.png]


* - -Various - Jun 28, 2016

(Jun 28, 2016 11:00 AM)Odus Wrote:  Not his fault you can't even use your clipboard correctly.

[Image: 3d835fd37e9542e86029ea75f7de2965.png]
I copy pasted it exactly


* - Neos07 - Jun 28, 2016

(Jun 28, 2016 11:08 AM)-Various Wrote:  I copy pasted it exactly

Please provide a screenshot of that part of code.


* - breaker1911 - Jun 28, 2016

you just need to set the right name of the folder
like this
Code
import system.io
try
if file.exists(yourfiles path) then
file.setattributes("Your files path" , Attribute)
else
msgbox("file not found")
end if
catch ex as exception
msgbox(ex.message)
end try
if some exception happen, write it here and i will see if i can help


you can use this instead %appdata%
Code
my.computer.specialdirectory.appdata

if i don't wrong, it will work.


* - Zettabit - Jun 28, 2016

(Jun 28, 2016 11:08 AM)-Various Wrote:  I copy pasted it exactly

Just re-write that line, not C+P it and it should work. Visual Studio does stupid shit occasionally, which is probably why it's giving you errors.