Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TuToRiAl] How to Delete a file in Visual Basic
#1
Hello everyone. Today I will be showing you how to delete a file in Visual Basic. Very simple and short code.

First of all due to security changes between OS', the deleting files method requires Administrator Privileges.

How to delete a file the proper way.

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        My.Computer.FileSystem.DeleteFile("C:\Users\John\Desktop\Test\Mountains.jpg")
    End Sub

This file is targeting the Mountains image in the test folder on the desktop.

And another way for deleting a file is called Kill. (very interesting name.)

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Kill("C:\Users\John\Desktop\Test\Mountains.jpg")
    End Sub
[Image: t5BWm.png]
Reply


Messages In This Thread
[TuToRiAl] How to Delete a file in Visual Basic - by Resistance - 10-04-2010, 06:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How To make an advanced Operating System in Visual Basic 2010 ? Mohamed Samir 9 12,437 01-15-2013, 09:30 PM
Last Post: Resistance
  [TuToRiAl] How to make Offline (No Internet) Captcha (Human Confirmation) [TuToRiAl] Resistance 24 12,502 08-30-2012, 10:14 PM
Last Post: Resistance
  [Visual Basic] FTP Uploader [Tutorial] Coding Support 6 3,001 08-12-2012, 12:36 AM
Last Post: Kenneth
  Visual Studio Bill Nye The Science Guy 1 1,028 03-19-2012, 09:08 AM
Last Post: BreShiE
  Visual Basic Guide - Buttons Death Demise 9 5,293 03-09-2012, 06:46 PM
Last Post: BreShiE

Forum Jump:


Users browsing this thread: 1 Guest(s)