Articles → ASP .NET WEB API → Call Web API Delete Method Using C#

Call Web API Delete Method Using C#






Web API Delete Method




[HttpDelete]
public void DeleteAllFiles(string folderName) {
	if (File.Exists(string.Format(@"c:\{0}\InsertData.txt", folderName))) 
		File.Delete(string.Format(@"c:\{0}\InsertData.txt", folderName));

	if (File.Exists(string.Format(@"c:\{0}\InsertDataForEmployee.txt", folderName))) 
		File.Delete(string.Format(@"c:\{0}\InsertDataForEmployee.txt", folderName));
}





Console Application




HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:40003/");
var response = client.DeleteAsync("api/PassParam?folderName=temp").Result;
if (response.IsSuccessStatusCode) {
	Console.WriteLine("Web API called successfully");
}
else 
	Console.WriteLine("There is some issue.");





Posted By  -  Karan Gupta
 
Posted On  -  Sunday, March 20, 2016

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250