 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can delete a file using a C program. Before starting you can note how you can search my YouTube channel. You can type my name Sanjay Gupta in YouTube search. My channel will be available there. You can watch various programming related videos here. Now I am going to implement a code with the help of C program which will delete a file that is stored in your computer's hard disk. So first I am including a header file that is stdio.h. Now I am going to define main function. Inside main function I have to call a function that is removed and inside this function I have to pass name of the file which I want to delete. So this source code is saved with test.c name and the location is C, T, C and bin folder. So now I am going to open bin folder for you. So C, T, C, bin it is containing various files and test.c is also saved in this folder. Now here you can see a text file is available that is data1.txt and it is a notepad file. I want to delete this data1.txt from this bin folder. So now I am going to write name of this file data1.txt in the function remove. So remove function deletes the file whose name will be available as an argument in this function. So if you are passing only name of the file then it will search this file in the current directory. So current directory is C, T, C and bin because source code that is stored in test.c is stored in bin folder. So this data1.txt will be searched in bin folder if it is available then it will be removed from bin folder. Now after execution of this remove function I can print the message file is deleted successfully. So this message will be printed on output screen and then I am writing return 0. So data1.txt will be deleted automatically with the help of remove function and remove function will be checking this file in the current directory and current directory is C, T, C and bin. So now I am going to execute this code so that you can understand how we can delete a file with the help of C program. So you can see the output. It is showing file is deleted successfully. Now I am moving to bin folder. Here you can see data.txt is not available. It is deleted successfully. So previously bin folder was containing data1.txt but right now it is not available in this folder. So this way if you want to delete a file from your current path then you can just pass name of a particular file and it will be removed automatically. Now you might be thinking if we want to delete a particular file which is available in another path like in D drive or E drive or in any drive. So for example now I am opening D drive inside D drive I have a folder demo and inside this demo folder I have two files sanjay.txt and test.txt. So I want to delete sanjay.txt file now which is available in D drive. So now I have to mention complete path here that is D demo slash sanjay.txt. So you can see I am mentioning complete path here that sanjay.txt is available in demo folder and demo folder is available in D drive. So now again I am going to execute this code. You can see it is showing the message file is deleted successfully. Now let's check whether the file is available in demo folder or not. You can see sanjay.txt file is not available here. It is deleted permanently from this computer's hard disk. So this way you can delete a file from your current path as well as from any particular path which is available in your computer's hard disk. So I hope you have understood both the methods which I have demonstrated you in this video. If you want to watch more programming related videos you can search my name sanjay gupta in YouTube. My channel will be available there. You can also download my android app Takamis which is available on Play Store. Thank you for watching this video.