Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4099724
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:28:18+00:00 2026-05-20T20:28:18+00:00

I have files that I want to delete. Connection can be from file sharing,

  • 0

I have files that I want to delete. Connection can be from file sharing, http, and ftp.

Example of files to delete:

//mytest//delete//filename.bin
ftp://mytest/delete/filename.bin
http://mytest/delete/filename.bin

Here’s what I did:

Uri target = new Uri(@"ftp://mytest/delete/filename.bin");
FileInfo fi = new FileInfo(target.AbsoluteUri);
fi.Delete();

The error I get is:

The given paths format is not supported

Is there a single code that can delete in all these file types?

I have created a simple code for this task(based on thread response).
This is the input:

Uri target = new Uri(@"ftp://tabletijam/FileServer/upload.bin");
Uri target = new Uri(@"http://tabletijam/FileServer/upload.bin");
Uri target = new Uri(@"\\tabletijam\FileServer\upload.bin");

This is the code:

bool DeleteFileOnServer(Uri serverUri)
{
    if (serverUri.Scheme == Uri.UriSchemeFtp)
    {
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
        request.Method = WebRequestMethods.Ftp.DeleteFile;

        FtpWebResponse response = (FtpWebResponse)request.GetResponse();
        lblStatus.Content = response.StatusDescription;

        response.Close(); 

        return true;
    }
    else if (serverUri.Scheme == Uri.UriSchemeFile)
    {
        System.IO.File.Delete(serverUri.LocalPath);

        return true;
    }
    else if (serverUri.Scheme == Uri.UriSchemeHttp || serverUri.Scheme == Uri.UriSchemeHttps)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serverUri);
        request.Method = WebRequestMethods.Http.DeleteFile;

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        lblStatus.Content = response.StatusDescription;

        response.Close();

        return true;
    }
    else
    {
        lblStatus.Content = "Unknown uri scheme.";
        return false;
    }
}

Ftp and File deleted successfully. WebRequestMethods.Http does not contain DeleteFile.

So my question is, how do I delete file from this URI?

http://tabletijam/FileServer/upload.bin
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:28:23+00:00Added an answer on May 20, 2026 at 8:28 pm

    Because FileInfo only works with local files. For each connection you will need a special implementation.

    For FTP: (example from MSDN)

    public static bool DeleteFileOnServer(Uri serverUri)
    {
        // The serverUri parameter should use the ftp:// scheme.
        // It contains the name of the server file that is to be deleted.
        // Example: ftp://contoso.com/someFile.txt.
        // 
    
        if (serverUri.Scheme != Uri.UriSchemeFtp)
        {
            return false;
        }
        // Get the object used to communicate with the server.
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
        request.Method = WebRequestMethods.Ftp.DeleteFile;
    
        FtpWebResponse response = (FtpWebResponse) request.GetResponse();
        Console.WriteLine("Delete status: {0}",response.StatusDescription);  
        response.Close();
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 wav files that I want to concatenate into one file with
I have a number of generated .sql files that I want to run in
Question We have a large number of xml configuration files that we want merged
Suppose that you have two huge files (several GB) that you want to concatenate
I only want a list of files that have been added (not ones that
I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in
I have a big load of documents, text-files, that I want to search for
I have a file that I want to include in Python but the included
I have a file that I want to read in using the File::Slurp module
I have an input file that I want to sort based on timestamp which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.