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 498855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:55:33+00:00 2026-05-13T05:55:33+00:00

For one of my projects we utilize a Content Delivery Network ( EdgeCast )

  • 0

For one of my projects we utilize a Content Delivery Network (EdgeCast) and I was wondering if anyone knew of an existing (open source) library for C# that we could leverage? In a nutshell, I am investigating the ability to create directories, upload files, and allow some general maintenance (rename files, delete files) via our admin panel. Any insight would be appreciated.


NOTE: My code to do this. I don’t know if they have an updated API at this point so please check. This code is circa 2009 (as-is, no warranties, use at your own risk, etc).

EdgeCast.cs

using System;
using edgeCastWS = [DOMAIN].com.edgecast.api.EdgeCastWebServices;

namespace [DOMAIN].IO.ContentDeliveryNetwork
{
    /// <summary>
    /// <b>Authentication</b>
    /// <para>Each web service call will include a string parameter called strCredential which will ensure that customers may only access data related to their own accounts. This credential is a string made up of a few separate pieces of information.</para>
    /// <para>A typical credential a customer would use may look like: “c:bas:user@email.com:password”</para>
    /// <para> * The field format of this string is delimited with a colon “:” character.</para>
    /// <para> * The first field is the type of client which is calling the web service. “c” represents an individual customer.</para>
    /// <para> * The second field is the security type. “bas” represents Basic Authentication.</para>
    /// <para> * With basic authentication the third field is the username which is usually in email address notation.</para>
    /// <para> * With basic authentication the fourth field is the password associated with the user.</para>
    /// <para>If the username and password are not valid, then the credential will prevent the specified function from proceeding. A SOAP exception will be generated and sent back to the client that called the function. The message contained in the exception will contain the string “Access Denied.”</para>
    /// </summary>
    public class EdgeCast : IDisposable
    {
        #region Declarations
        [ThreadStatic]
        private static EdgeCast _current;
        private static EdgeCastCredential _credential = null;
        private static string _customerID = string.Empty;
        private static edgeCastWS _edgeCastWS = null;
        #endregion

        #region Constructor
        public EdgeCast()
        {
            if (_current != null)
            {
                throw new InvalidOperationException("Only one ContentDeliveryNetwork may be created on a given thread.");
            }
            _current = this;
            _edgeCastWS = new edgeCastWS();
            ConstructCredentials();
            _customerID = AppSettings.EdgeCast_CustomerID;
        }
        #endregion

        #region API Methods
        /// <summary>
        /// Purges a file from all of the EdgeCast caching servers. This process may take a few minutes to fully complete.
        /// </summary>
        /// <param name="Path">This is path of the file or folder to purge, in URL format. To specify a folder, please put a trailing slash at the end of the URL. All files under that folder will be purged</param>
        /// <param name="MediaType">HTTP Large Object = 3, HTTP Small Object = 8, Flash = 2, Windows = 1</param>
        /// <returns>An integer that indicates whether or not the transaction was successful. 0 represents yes, -1 represents no</returns>
        internal static short PurgeFileFromEdge(string Path, int MediaType)
        {
            return _edgeCastWS.PurgeFileFromEdge(_credential.Credential, _customerID, Path, MediaType);
        }
        /// <summary>
        /// Loads a file to disk on all of the EdgeCast caching servers. This process may take a few minutes to fully complete.
        /// </summary>
        /// <param name="Path">This is path of the file to load, in URL format. Folders may not be loaded and will be ignored</param>
        /// <param name="MediaType">HTTP Large Object = 3, HTTP Small Object = 8</param>
        /// <returns>An integer that indicates whether or not the transaction was successful. 0 represents yes, -1 represents no</returns>
        internal static short LoadFileToEdge(string Path, int MediaType)
        {
            return _edgeCastWS.LoadFileToEdge(_credential.Credential, _customerID, Path, MediaType);
        }
        /// <summary>
        /// This method call is used to add a token authentication directory. All additions and changes should be processed every 30 minutes
        /// </summary>
        /// <param name="Dir">Directory Path should be starting from the root. Example: /directory1/directory2</param>
        /// <param name="MediaType">Use 1 for Windows, 2 for Flash, 3 for HTTP Caching / Progressive download.</param>
        /// <returns></returns>
        internal static short TokenDirAdd(string Dir, int MediaType)
        {
            return _edgeCastWS.TokenDirAdd(_credential.Credential, _customerID, Dir, MediaType);
        }
        internal static string TokenEncrypt(string Key, string Args)
        {
            return _edgeCastWS.TokenEncrypt(_credential.Credential, Key, Args);
        }
        internal static short TokenKeyUpdate(string Key, int MediaType)
        {
            return _edgeCastWS.TokenKeyUpdate(_credential.Credential, _customerID, Key, MediaType);
        }
        #endregion

        #region FTP Methods
        /// <summary>
        /// Does a FTP Upload of a file on the local system
        /// </summary>
        /// <param name="targetPath">The full path to save to on the FTP server (.\Campaigns\Prod\[Company GUID])</param>
        /// <param name="sourceFileName">The full path and filename of the file to be uploaded (C:\[DOMAIN]\files\[filename])</param>
        internal static void FTP_UploadFile(string targetPath, string sourceFileName)
        {
            string[] dirs = targetPath.Split(new char[] { '\\', '/' });

            using (FTPFactory myFTP = new FTPFactory())
            {
                myFTP.login();
                myFTP.setBinaryMode(true);

                // Make sure the directories are there and change down to the bottom most directory...
                foreach (string dirName in dirs)
                {
                    bool dirExists = true;
                    try { myFTP.chdir(dirName); }
                    catch { dirExists = false; }
                    if (!dirExists)
                    {
                        myFTP.mkdir(dirName);
                        myFTP.chdir(dirName);
                    }
                }

                // upload the file now...
                myFTP.upload(sourceFileName);
            }
        }
        /// <summary>
        /// Returns a string array of files in the target directory
        /// </summary>
        /// <param name="targetPath">The target directory</param>
        /// <returns>string array or null if no files found</returns>
        internal static string[] FTP_GetFileList(string targetPath)
        {
            string[] dirs = targetPath.Split(new char[] { '\\', '/' });
            string[] files = null;

            using (FTPFactory myFTP = new FTPFactory())
            {
                myFTP.login();
                myFTP.setBinaryMode(true);

                // Make sure the directories are there and change down to the bottom most directory...
                foreach (string dirName in dirs)
                {
                    bool dirExists = true;
                    try { myFTP.chdir(dirName); }
                    catch { dirExists = false; }
                    if (!dirExists)
                    {
                        myFTP.mkdir(dirName);
                        myFTP.chdir(dirName);
                    }
                }

                // get the list of files now...
                files = myFTP.getFileList("*.*");
            }
            return files;
        }
        /// <summary>
        /// Checks to see if a file exists
        /// </summary>
        /// <param name="targetPath">The CDN directory path to look in</param>
        /// <param name="targetFile">The file to look for</param>
        /// <returns>true = found, false = not found</returns>
        internal static bool FTP_DoesFileExist(string targetPath, string targetFile)
        {
            bool retFlag = true;
            string[] dirs = targetPath.Split(new char[] { '\\', '/' });

            using (FTPFactory myFTP = new FTPFactory())
            {
                myFTP.login();
                myFTP.setBinaryMode(true);

                // change to the target directory - if it does not exists, neither does the file!  simple...
                foreach (string dirName in dirs)
                {
                    try { myFTP.chdir(dirName); }
                    catch { retFlag = false; }
                }
                if (retFlag)
                {
                    try { retFlag = myFTP.getFileSize(targetFile) > 0; }
                    catch { retFlag = false; }
                }
            }
            return retFlag;
        }
        internal static bool FTP_DoesFileExist(string targetFile)
        {
            string targetPath = targetFile.Replace(@"http://", "");
            targetPath = targetPath.Replace(@"https://", "");
            targetPath = targetPath.Replace(@"cdn1.[DOMAIN].com/", "");
            targetPath = targetPath.Replace(@"/", @"\");

            targetPath = targetPath.Substring(0, targetPath.LastIndexOf(@"\"));
            targetFile = targetFile.Substring(targetFile.LastIndexOf(@"/") + 1);
            return FTP_DoesFileExist(targetPath, targetFile);
        }
        #endregion

        #region Helper Methods
        static private string ConstructCredentials()
        {
            _credential = new EdgeCastCredential();
            return _credential.Credential;
        }
        static private string ConstructCredentials(string credentials)
        {
            _credential = new EdgeCastCredential(credentials);
            return _credential.Credential;
        }
        static private string ConstructCredentials(string typeOfClient, string securityType, string userName, string password)
        {
            _credential = new EdgeCastCredential(typeOfClient, securityType, userName, password);
            return _credential.Credential;
        }
        #endregion

        #region IDisposable Members
        public void Dispose()
        {
            _current = null;
        }
        #endregion
    }
}

EdgeCastCredential.cs

using System;
using rivSecurity = [DOMAIN].Security.Cryptography.Internal;

namespace [DOMAIN].IO.ContentDeliveryNetwork
{
    internal class EdgeCastCredential
    {
        #region Properties
        public string TypeOfClient;
        public string SecurityType;
        public string UserName;
        public string Password;
        public string Credential { get { return String.Format("{0}:{1}:{2}:{3}", TypeOfClient, SecurityType, UserName, Password); } }
        #endregion

        #region Constructor
        public EdgeCastCredential()
        {
            TypeOfClient = AppSettings.EdgeCast_TypeOfClient;
            SecurityType = AppSettings.EdgeCast_SecurityType;
            UserName = rivSecurity.Decrypt(AppSettings.EdgeCast_UserName);
            Password = rivSecurity.Decrypt(AppSettings.EdgeCast_Password);
        }
        public EdgeCastCredential(string credentials)
        {
            string[] parts = credentials.Split(new char[] { ':' });
        }
        public EdgeCastCredential(string typeOfClient, string securityType, string userName, string password)
        {
            TypeOfClient = typeOfClient;
            SecurityType = securityType;
            UserName = userName;
            Password = password;
        }
        #endregion
    }
}
  • 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-13T05:55:34+00:00Added an answer on May 13, 2026 at 5:55 am

    Never mind. I created a FTP library and used what little they had for an API. I can not now read/upload/delete files and purge the CDN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a solution that has two projects: One ASP.NET web application, and
As part of one of my projects, there are BeforeBuild tasks that ultimately generate
I have two projects in a workspace, one is a fancy application that is
I've got a junk directory where I toss downloads, one-off projects, email drafts, and
One of my projects use the MyISAM engine in MySQL, but I'm considering changing
In one of my projects I need to build an ASP.NET page and some
In one of the projects I've worked on, the subject of isomorphism versus monomorphism
I have several web application projects in one solution. When I start debugging one
I have 2 projects each one with its own unit test project, and one
I started using subversion for one of my projects and it would be absolutely

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.