|
-
Aug 16th, 2006, 02:19 PM
#1
Thread Starter
New Member
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.
-
Aug 16th, 2006, 02:21 PM
#2
Fanatic Member
Re: making a file unhidden?
VB Code:
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!
-
Aug 16th, 2006, 02:24 PM
#3
Re: making a file unhidden?
VB Code:
Private Const source As String = "C:\MyHidden.txt"
Private Const dest As String = "C:\MyExposed.txt"
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
IO.File.Copy(source, dest, True)
IO.File.SetAttributes(dest, IO.FileAttributes.Normal)
Catch ex As Exception
End Try
Bah, late
Last edited by sevenhalo; Aug 16th, 2006 at 02:25 PM.
Reason: late
-
Aug 16th, 2006, 02:26 PM
#4
Fanatic Member
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!
-
Aug 16th, 2006, 03:06 PM
#5
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:
Private Const source As String = "C:\demo.txt"
Private Const dest As String = "C:\Mydemo.txt"
Private Delegate Sub delCopy(ByVal strSource As String, ByVal strDest As String)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim callback As New delCopy(AddressOf CopyFile)
Try
callback.BeginInvoke(source, dest, New AsyncCallback(AddressOf CopyComplete), dest)
Catch ex As Exception
'handle
End Try
End Sub
Private Sub CopyFile(ByVal strSource As String, ByVal strDest As String)
IO.File.Copy(strSource, strDest)
End Sub
Private Sub CopyComplete(ByVal ia As IAsyncResult)
If ia.IsCompleted Then
IO.File.SetAttributes(ia.AsyncState.ToString, IO.FileAttributes.Normal)
End If
End Sub
This way, if you're copying uber-big files; the attributes are set after the copy completes.
-
Aug 16th, 2006, 03:10 PM
#6
Fanatic Member
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!
-
Aug 16th, 2006, 03:12 PM
#7
Re: making a file unhidden?
That "line of code" was the same one I suggested.
-
Aug 16th, 2006, 03:14 PM
#8
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|