File help

Posts 1–9 of 9 · Page 1 of 1
[HELP]File writing
Hello i want to find the most efficient way to delete a file in directory
Code:
C:\WINDOWS\system32\drivers\etc\HOSTS
which i think i would use the kill command and then replace it with a file called HOSTS too with a press of a button then use a simple if-then statement to show success.

,thanks in advance
System.IO.File.Delete("C:\WINDOWS\system32\drivers \etc\HOSTS\*")

?
Quote Originally Posted by benl View Post
Hello i want to find the most efficient way to delete a file in directory
Code:
C:\WINDOWS\system32\drivers\etc\HOSTS
which i think i would use the kill command and then replace it with a file called HOSTS too with a press of a button then use a simple if-then statement to show success.

,thanks in advance
Code:
Dim file as string="C:\WINDOWS\system32\drivers\etc\HOSTS\Filename.txt"
My.Computer.FileSystem.DeleteFile(file, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently, FileIO.UICancelOption.DoNothing)
Code:
C:\Windows\System32\drivers\etc
Sorry, put that in windows explorer and look down and you should see a file called "hosts"...i want to delete the existing and replace it with a new one called "hosts" too...it is for a activation blocker for CS5 to not let the activator connect to the internet to check if a key is legit.
Quote Originally Posted by benl View Post
Code:
C:\Windows\System32\drivers\etc
Sorry, put that in windows explorer and look down and you should see a file called "hosts"...i want to delete the existing and replace it with a new one called "hosts" too...it is for a activation blocker for CS5 to not let the activator connect to the internet to check if a key is legit.
Code:
Dim newFile as string="Location+Filename"
My.Computer.Filesystem.copyFile(NewFile,"C:\WINDOWS\system32\drivers\etc\hosts",true)
Replace "Location+Filename" with the location and name of the host file you want to be replaced. For example if its in your D Drive, then it would be:
Code:
"D:\host"
OR if it's in another folder then:

Code:
"D:\Somefolder\host"
This would replace the existing file.
Thanks i will see if it works and is there a way to not have to use run as admin in win7 since you are modifying/changing a file because it may cause a problem?
File.Delete("C:\WINDOWS\system32\drivers\etc\hosts ")

Quote Originally Posted by Hassan View Post


Code:
Dim file as string="C:\WINDOWS\system32\drivers\etc\HOSTS\Filename.txt"
My.Computer.FileSystem.DeleteFile(file, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently, FileIO.UICancelOption.DoNothing)
"hosts" is not a folder - it's your TCP local DNS resolution file.

Quote Originally Posted by benl View Post
Thanks i will see if it works and is there a way to not have to use run as admin in win7 since you are modifying/changing a file because it may cause a problem?
Disable UAC - it's a Windows restriction to prevent viruses and malware from wreaking havoc with your computer.
Quote Originally Posted by freedompeace View Post
File.Delete("C:\WINDOWS\system32\drivers\etc\hosts ")



"hosts" is not a folder - it's your TCP local DNS resolution file.



Disable UAC - it's a Windows restriction to prevent viruses and malware from wreaking havoc with your computer.
He made a correction and told that its a file. So see my last post.

Also, disabling UAC is poor method. Taking control of file is much better way.
Quote Originally Posted by Hassan View Post


He made a correction and told that its a file. So see my last post.

Also, disabling UAC is poor method. Taking control of file is much better way.
I know, I was explaining what UAC is / what it does.
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?