locked
Change attribute of a file?? RRS feed

  • Question

  • I want to change an attribute of a file thru VB..
    Can it be possible??? Plz help me if any one knows...

    Means I want to make a file hidden or unhidden thru Vb application...
    Plz help..............
    Monday, September 3, 2007 11:17 AM

Answers

  • You can use the File and FileAttributes objects in VB .NET...

    File.SetAttributes("" & filenamestring & "", FileAttributes.Hidden)

    I don't know of any direct way of making a file unhidden. One (roundabout) way of doing it is to check if the file is ReadOnly and/or System file, and then set those attributes alone. In this way, Hidden attribute will go off...

    If((File.GetAttributes("" & filenamestring & "") And FileAttributes.System) = FileAttributes.System) And (((File.GetAttributes("" & filenamestring & "") And FileAttributes.ReadOnly) = FileAttributes.ReadOnly) And) Then

    File.SetAttributes("" & filenamestring & "", FileAttributes.System + FileAttributes.ReadOnly)

    End If


    http://www.devasp.net/net/articles/display/340.html  will probably help you...



    Thursday, September 6, 2007 7:06 AM

All replies

  • You can use the File and FileAttributes objects in VB .NET...

    File.SetAttributes("" & filenamestring & "", FileAttributes.Hidden)

    I don't know of any direct way of making a file unhidden. One (roundabout) way of doing it is to check if the file is ReadOnly and/or System file, and then set those attributes alone. In this way, Hidden attribute will go off...

    If((File.GetAttributes("" & filenamestring & "") And FileAttributes.System) = FileAttributes.System) And (((File.GetAttributes("" & filenamestring & "") And FileAttributes.ReadOnly) = FileAttributes.ReadOnly) And) Then

    File.SetAttributes("" & filenamestring & "", FileAttributes.System + FileAttributes.ReadOnly)

    End If


    http://www.devasp.net/net/articles/display/340.html  will probably help you...



    Thursday, September 6, 2007 7:06 AM
  • Thanks a lot Sundara....

    Sunday, September 9, 2007 4:14 PM
  • hi we change the attributes of vb but i dono how
    Tuesday, September 11, 2007 12:03 PM
  •  Sundara _Raman_4b6e68 wrote:
    You can use the File and FileAttributes objects in VB .NET...

    File.SetAttributes("" & filenamestring & "", FileAttributes.Hidden)

    I don't know of any direct way of making a file unhidden. One (roundabout) way of doing it is to check if the file is ReadOnly and/or System file, and then set those attributes alone. In this way, Hidden attribute will go off...

    If((File.GetAttributes("" & filenamestring & "") And FileAttributes.System) = FileAttributes.System) And (((File.GetAttributes("" & filenamestring & "") And FileAttributes.ReadOnly) = FileAttributes.ReadOnly) And) Then

    File.SetAttributes("" & filenamestring & "", FileAttributes.System + FileAttributes.ReadOnly)

    End If


    http://www.devasp.net/net/articles/display/340.html  will probably help you...






    its not working......
    Wednesday, September 12, 2007 12:40 PM