Results 1 to 8 of 8

Thread: making a file unhidden?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    11

    making a file unhidden?

    hey everyone i have got a hidden file that i am copying to a different folder, and when i copy the file over i want it to become visable and not hidden anymore anybody any ideas?

    thanks in advance.

  2. #2
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: making a file unhidden?

    VB Code:
    1. System.IO.File.SetAttributes("path", IO.FileAttributes.Normal)
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  3. #3
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: making a file unhidden?

    VB Code:
    1. Private Const source As String = "C:\MyHidden.txt"
    2.     Private Const dest As String = "C:\MyExposed.txt"
    3.     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Try
    5.             IO.File.Copy(source, dest, True)
    6.             IO.File.SetAttributes(dest, IO.FileAttributes.Normal)
    7.         Catch ex As Exception
    8.  
    9.         End Try

    Bah, late
    Last edited by sevenhalo; Aug 16th, 2006 at 02:25 PM. Reason: late

  4. #4
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: making a file unhidden?

    sevenhalo, you'd have been on time except it was that I had to test my idea; I've never actually set file attributes before...
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  5. #5
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: making a file unhidden?

    Yeah, I had to test it too.

    The solution looked too simple though; so I'm going to complicate things a little:
    VB Code:
    1. Private Const source As String = "C:\demo.txt"
    2.     Private Const dest As String = "C:\Mydemo.txt"
    3.  
    4.     Private Delegate Sub delCopy(ByVal strSource As String, ByVal strDest As String)
    5.  
    6.     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7.         Dim callback As New delCopy(AddressOf CopyFile)
    8.  
    9.         Try
    10.             callback.BeginInvoke(source, dest, New AsyncCallback(AddressOf CopyComplete), dest)
    11.         Catch ex As Exception
    12.             'handle
    13.         End Try
    14.     End Sub
    15.  
    16.     Private Sub CopyFile(ByVal strSource As String, ByVal strDest As String)
    17.         IO.File.Copy(strSource, strDest)
    18.     End Sub
    19.     Private Sub CopyComplete(ByVal ia As IAsyncResult)
    20.         If ia.IsCompleted Then
    21.             IO.File.SetAttributes(ia.AsyncState.ToString, IO.FileAttributes.Normal)
    22.         End If
    23.     End Sub
    This way, if you're copying uber-big files; the attributes are set after the copy completes.

  6. #6
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: making a file unhidden?

    Looks far better than my one...measly...tiny...line of code...

    Your code will come in handy for me too Thanks
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  7. #7
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: making a file unhidden?

    That "line of code" was the same one I suggested.

  8. #8
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: making a file unhidden?

    Well yes, but now yours is a nice and elegant and (by coding standard), sexy code machine that will do so much more than mine...
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width