Delete file

I

id10t error

Hello,

I am making a program that will not have an user interaction to delete
certian files. I found this line of code.
My.Computer.FileSystem.DeleteFile("C:\POLLJP.DWN",
FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)
The problem is that a message box comes up and asks "Are you sure you
want to delete file"file name yes or no". Does anyone know a way
around this. I want it to delete everytime no questions asked .Thank
you
 
K

kimiraikkonen

Hello,

I am making a program that will not have an user interaction to delete
certian files. I found this line of code.
My.Computer.FileSystem.DeleteFile("C:\POLLJP.DWN",
FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)
The problem is that a message box comes up and asks "Are you sure you
want to delete file"file name yes or no". Does anyone know a way
around this. I want it to delete everytime no questions asked .Thank
you

That's because you're passing FileIO.UIOption enum as "AllDialogs"
then simply change your code to:

My.Computer.FileSystem.DeleteFile("C:\POLLJP.DWN",
FileIO.UIOption.OnlyErrorDialogs,
FileIO.RecycleOption.DeletePermanently)

Thanks,

Onur Güzel
 
Z

zacks

Hello,

I am making a program that will not have an user interaction to delete
certian files. I found this line of code.
My.Computer.FileSystem.DeleteFile("C:\POLLJP.DWN",
FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)
The problem is that a message box comes up and asks "Are you sure you
want to delete file"file name yes or no". Does anyone know a way
around this. I want it to delete everytime no questions asked .Thank
you

The File.Delete method does not present the user with a nag box. But I
am not sure if it can permanently delete the file.

I think the File class is in the System.IO namespace.
 
M

Martin H.

Or you could use the good old "Kill" command.
Kill "C:\POLLJP.DWN" will permanently delete that file.
 
K

kimiraikkonen

The File.Delete method does not present the user with a nag box. But I
am not sure if it can permanently delete the file.

I think the File class is in the System.IO namespace.

As OP requests, with "DeleteFile" method in My namespace, a file can
be deleted permanently without any user interaction of confirmation,
except errors(see 2nd and 3rd parameters):

My.Computer.FileSystem.DeleteFile("C:\POLLJP.DWN",
FileIO.UIOption.OnlyErrorDialogs,
FileIO.RecycleOption.DeletePermanently)

unless you try to recover with a recovery software of course :)

Thanks,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top