I write the code below to delete a file:
FileInfo file = new FileInfo(filename);
file.Delete(Path);
but I am getting the error that file.Delete(path) takes 1 argument please help me
I write the code below to delete a file:
FileInfo file = new FileInfo(filename);
file.Delete(Path);
but I am getting the error that file.Delete(path) takes 1 argument please help me
You are creating an instance of FileInfo having a filename as an arguement. Method file.Delete() will remove the file which you passed through a constructor. In fact, the argument of constructor must be an absolute path along with filename.
String filename=@"c:\xyz\aa.txt";
FileInfo file=new FileInfo(filename);
file.Delete();
Your use of FileInfo.Delete takes no arguments.
You want something like:
FileInfo file = new FileInfo(filename);
file.Delete();
Your code should be as below :
FileInfo file = new FileInfo(filename);
file.Delete();
The Delete method of FileInfo object does not take any arguments.