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.
Printable View
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.
VB Code:
System.IO.File.SetAttributes("path", IO.FileAttributes.Normal)
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 :mad:
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... :)
Yeah, I had to test it too. :D
The solution looked too simple though; so I'm going to complicate things a little:
This way, if you're copying uber-big files; the attributes are set after the copy completes.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
Looks far better than my one...measly...tiny...line of code... :)
Your code will come in handy for me too :D Thanks
That "line of code" was the same one I suggested. ;)
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...