Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. set the property of the file created to be hidden

set the property of the file created to be hidden

Scheduled Pinned Locked Moved C#
questioncsharp
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    batmanAgen
    wrote on last edited by
    #1

    hi guys, how can i set the file that i create using c# (FileStream) to be automatically hidden or read-only? i dont want the client users to have access to that file that is why i want to hide it.. if there's a better way of doing this, im open to suggestions.. tnx in advance!:D

    W 1 Reply Last reply
    0
    • B batmanAgen

      hi guys, how can i set the file that i create using c# (FileStream) to be automatically hidden or read-only? i dont want the client users to have access to that file that is why i want to hide it.. if there's a better way of doing this, im open to suggestions.. tnx in advance!:D

      W Offline
      W Offline
      Wayne Phipps
      wrote on last edited by
      #2

      I think you have to use the File object in the System.IO namespace. It would go something like: File.SetAttributes(path, FileAttributes.Hidden); See the following URL for reference: File.SetAttributes Method Hope this helps. Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog

      B 1 Reply Last reply
      0
      • W Wayne Phipps

        I think you have to use the File object in the System.IO namespace. It would go something like: File.SetAttributes(path, FileAttributes.Hidden); See the following URL for reference: File.SetAttributes Method Hope this helps. Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog

        B Offline
        B Offline
        batmanAgen
        wrote on last edited by
        #3

        Thanks for the immediate reply.. :) here's a follow up question. is it possible for the folder which contains the file to set its attribute also to hidden?:)

        W 1 Reply Last reply
        0
        • B batmanAgen

          Thanks for the immediate reply.. :) here's a follow up question. is it possible for the folder which contains the file to set its attribute also to hidden?:)

          W Offline
          W Offline
          Wayne Phipps
          wrote on last edited by
          #4

          Have you looked at the DirectoryInfo object in the System.IO namespace? It also has Attributes member. Your code would be something like:

          DirectoryInfo di = new DirectoryInfo(@"c:\Test");
          di.Attributes = FileAttributes.Hidden;
          

          Hope this helps. Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog

          B 1 Reply Last reply
          0
          • W Wayne Phipps

            Have you looked at the DirectoryInfo object in the System.IO namespace? It also has Attributes member. Your code would be something like:

            DirectoryInfo di = new DirectoryInfo(@"c:\Test");
            di.Attributes = FileAttributes.Hidden;
            

            Hope this helps. Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog

            B Offline
            B Offline
            batmanAgen
            wrote on last edited by
            #5

            thanks wayne! it workd..:D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups